此For-Loop完全执行了我想要的操作,但是似乎很难退出循环并继续下面的更多代码。不明白为什么会出现类型不匹配的情况
我正在使用相同的确切代码块,以进行更多从不同来源进行复制和粘贴到主表的记录,因此效果很好。由于某种原因,这一特定代码与众不同,并且没有明显的原因,因为我实际上只是复制并粘贴了代码,并在以后的代码块中更改了工作表名称
Dim a As Long
Dim b As Long
b = 2
Worksheets.Add(After:=Worksheets("Tour Info")).Name = "Optional Excursions"
Workbooks("Tour Code Optionals").Worksheets("2019 Internal Descriptions").Range("A1:Z1").Copy
Workbooks("AAB").Worksheets("Optional Excursions").Range("A1:Z1").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks("AAB").Worksheets("Optional Excursions").Range("A1:Z1").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
For a = 2 To 422
If InStr(Workbooks("Tour Code Optionals").Worksheets("2019 Internal Descriptions").Range("C" & a), Workbooks("AAB").Worksheets("Tour Info").Range("A1")) > 0 Then
Workbooks("Tour Code Optionals").Worksheets("2019 Internal Descriptions").Range("A" & a, "Z" & a).Copy
Workbooks("AAB").Worksheets("Optional Excursions").Range("A" & b, "Z" & b).PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks("AAB").Worksheets("Optional Excursions").Range("A" & b, "Z" & b).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
b = b + 1
End If
Next