[英]Dynamic range for vlookup in Excel VBA
我正在尋找設置動態范圍的可能性。 問題在於Excel不接受鍵入。 對於每個a,應查看矩陣的五行。 vlookup在固定范圍內工作,例如“ E43:AT47”,但不適用於組合范圍。
Range_Zeile_Start = 5 * a - 12
Range_Zeile_End = 5 * a - 8
Range_Count = "R" & Range_Zeile_Start & "C5:R" & Range_Zeile_End & "C46"
Fahrzeit_kk = Application.WorksheetFunction.VLookup(Cells(1, b).Value, Range_Count, 42, False)
您需要正確設置范圍。
參見下面的代碼:
Dim VlookRng As Range
Range_Zeile_Start = 5 * a - 12
Range_Zeile_End = 5 * a - 8
' set up the Range for the Vlookup
Set VlookRng = Range(Cells(Range_Zeile_Start, 5), Cells(Range_Zeile_End, 46))
Fahrzeit_kk = Application.WorksheetFunction.VLookup(Cells(1, b).value, VlookRng, 42, False)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.