gpt4 book ai didi

VBA 偏移函数给出 Synthaxis 错误

转载 作者:行者123 更新时间:2023-12-04 20:12:52 25 4
gpt4 key购买 nike

目前在宏上执行 VBA 的最后一位。此宏旨在通过使用 Findstring 的输入框,找到一行,将其复制到不同的工作表,将此行粘贴到第一个空行上,然后删除原始工作表上的行。

If Not Rng Is Nothing Then
Rng.EntireRow.Copy
Worksheets("ScrapLogboek").Cells(Rows.Count, "A").End(xlUp).Offset(1, -1)
Worksheets("ScrapLogboek").Range("A2").PasteSpecial
Rng.EntireRow.Delete
Else
MsgBox ("Niks gescrapt. Check of het B-nummer correct is.")
End If

End With
MsgBox ("Logboek gescrapt.")
End If
End Sub

现在我在偏移函数上不断收到一个合成器错误。我究竟做错了什么?如评论中所述; Worksheets("ScrapLogboek").Cells(Rows.Count, "A").End(xlUp).Offset(1, -1)。出于某种原因,这条线让我大吃一惊。

最佳答案

您在 A栏 ,所以你不能偏移减去一列 因为左边没有其他人了 !

使用 Worksheets("ScrapLogboek").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) 尝试您的代码它会工作的! ;)

而且您的代码总是会粘贴在 A2 上,这可能不是目的,所以这里是更正的版本:

If Not Rng Is Nothing Then
Rng.EntireRow.Copy
Worksheets("ScrapLogboek").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
Rng.EntireRow.Delete
Else
MsgBox ("Niks gescrapt. Check of het B-nummer correct is.")
End If

End With
MsgBox ("Logboek gescrapt.")
End If
End Sub

关于VBA 偏移函数给出 Synthaxis 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34043594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com