对不起,如果我的英语不好 我有和excel工作簿4张,在工作表1,我使宏VBA查找工作表2中的值。它运行正常,但似乎Vlookup功能停在第104行。所以如果我搜索的项目是在行以上104,它返回0.
这是我的宏代码
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Err.Clear
Dim irange As Range
Dim icol As Integer
Dim irow, sResult As Integer
Dim cVal As String
Set myBook = Excel.ActiveWorkbook
Set mySheet1 = myBook.Sheets("Arus Inventory")
Set mySheet2 = myBook.Sheets("Data Inventory")
Set irange = ActiveCell
icol = ActiveCell.Column
irow = ActiveCell.Row
coltgt = icol + 2
If icol = 6 Then
cVal = Cells(irow, 5).Value
If irange = "BELI" Then
sResult = Application.WorksheetFunction.VLookup(cVal, Sheets("Data Inventory").Range("C5:E1004"), 3, False)
Cells(irow, coltgt).Value = sResult
Else
myValue = InputBox("MSRP: " & vbCrLf & vbCrLf & "Terjual dengan harga", "Kode Barang: " & cVal)
Cells(irow, coltgt).Value = myValue
End If
Range("G" & irow).Select
End If
End Sub
当我搜索的项目超过104行时,此脚本返回0
sResult = Application.WorksheetFunction.VLookup(cVal, Sheets("Data Inventory").Range("C5:E1004"), 3, False)
Cells(irow, coltgt).Value = sResult
我做错了什么? 感谢