0
我想用Vlookup
製作一個用戶表單。信息存儲在不同的工作簿中。如何使用下面的VBA代碼將我需要的信息從不同的Excel工作簿提取到我的文本字段中?vlookup從不同的excel工作簿中提取信息
Private Sub Textan_AfterUpdate()
'check to see if value exists
If WorksheetFunction.CountIf(C:\Users\poury\Desktop\ADDON Order Tool\AL010.xlsx.Sheet2.Range("B:B"), Me.Textan.Value) = 0 Then
MsgBox "This is an incorrect Article Number"
Me.Textan.Value = ""
Exit Sub
End If
With Me
Textan1 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 2, 0)
Textan2 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 3, 0)
Textan3 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 4, 0)
Textan4 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 5, 0)
Textan5 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 6, 0)
Textan6 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 7, 0)
Textan7 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 8, 0)
Textan8 = Application.WorksheetFunction.VLookup(CLng(Me.Textan), Sheet2.Range("Lookup"), 9, 0)
End With
End Sub
非常感謝您的回覆。它確實解決了我的問題 –
不客氣。您可能要標記接受的答案。謝謝 – user3598756
@PouryaAshena https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – 0m3r