需要有关运行时错误9下标超出范围的帮助

时间:2018-08-01 02:10:13

标签: vba excel-vba

我被要求修复其他人的VBA项目中的错误,但不幸的是,我对VBA还是很陌生。如果您能帮助我,将不胜感激。

所以这是下面的宏。我将数据从11个文件拉入单个excel工作表中,但它始终卡在第9个文件中。指出的错误是“运行时错误'9':下标超出范围” 。当我单击“调试”时,它会将我带到 Workbooks(Workbookname).Sheets(Target_Worksheet)下面的行。选择

Private Sub MasterPull(TargetPath, Quarter, Year)

Dim Target_Worksheet As String
Target_Worksheet = "Q" & Quarter & " " & Year
Dim Target_workbook As Workbook
Dim Source_Workbook As String
Source_Workbook = "Broker Captain Master.xlsm"

Dim Workbookname As String

Workbookname = Left(Mid(TargetPath, 38, 200), Len(Mid(TargetPath, 38, 200)) -5) & ".xlsx"

Set Target_workbook = Workbooks.Open(TargetPath, True, True, , "xxxxx")

Workbooks(Workbookname).Sheets(Target_Worksheet).Select

Dim HighTouchRow As Integer

HighTouchRow = WorksheetFunction.Match("High Touch (All teams)", 

Workbooks(Workbookname).Sheets(Target_Worksheet).Range("A9:A9999"), 0) + 8

感谢您的帮助!

0 个答案:

没有答案