我是这个VBA的新手,需要一些关于我的代码的帮助。我设法从O列的最后一行获取代码到vlookup,但我不知道如何填充它以匹配E列的最后一行。
我的目标是从O填充的最后一行到E
的最后一行进行vlookupif (Number(j)<=Number(holiday_ends)){
console.log("TRUE");
}
感谢您的帮助。
答案 0 :(得分:0)
您可以通过清除Select
/ Selection
和Activate
/ ActiveCell
来解决问题。
以下是您清理过的代码并使其更加清晰:
Dim JPNpart As String, PartNumber As String, myRange As String, LastRow As Long
JPNpart = "[JPN_part.xlsx]Sheet1"
myRange = "'" & JPNpart & "'!A:G"
With ThisWorkbook.Sheets("Sheet1")
'For column O
LastRow = .Range("O" & .Rows.Count).End(xlUp).Row
PartNumber = "B" & LastRow + 1
.Range("O" & LastRow).Offset(1, 0).Formula = "=VLOOKUP(" & PartNumber & "," & myRange & ", 7, FALSE)"
'For column E
LastRow = .Range("E" & .Rows.Count).End(xlUp).Row
PartNumber = "B" & LastRow + 1
.Range("E" & LastRow).Offset(1, 0).Formula = "=VLOOKUP(" & PartNumber & "," & myRange & ", 7, FALSE)"
End With 'ThisWorkbook.Sheets("Sheet1")