我不知道为什么我的VBA Excel代码无法运行。通知是“下标超出范围”:
Private Sub Jakarta_Click()
Dim lookFor As String
Dim srchRange As Range
Dim book1 As Workbook
Dim book2 As Workbook
Dim ws As Worksheet
Set book1 = Workbooks("Gabungan.xlm")
Set book2 = Workbooks("Template Kuantitatif Jakarta.xlm")
Set ws = book1.Sheets("JAKARTA")
With ws
lookFor = book1.Sheets("JAKARTA").Range(Cells(3, 1))
Set srchRange = book2.Sheets("FINAL").Range(Cells(3, 4).Address, Cells(39, 5).Address)
ws.Cells(3, 2).Value = Application.WorksheetFunction.VLookup(lookFor, book2.Sheets("FINAL").Range(srchRange.Address), 2, False)
End With
End Sub