0
Private Sub Search_Click()
On Error GoTo MyErrorHandler:
Dim PartNumber As String
Dim det As String
PartNumber = PartNumberIN.Text ' take part input from textbox
det = "Part Number: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 2), 3, False)
det = det & vbNewLine & "Part Description: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 4), 5, False)
det = det & vbNewLine & "CV or VA: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 1), 2, False)
det = det & vbNewLine & "Direct Ship?: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 3), 4, False)
det = det & vbNewLine & "Storage Container: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 6), 7, False)
det = det & vbNewLine & "SAP Location: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 13), 14, False)
det = det & vbNewLine & "Physical Location: " & Application.WorksheetFunction.VLookup(PartNumber, Application.WorksheetFunction.Offset(Table1, 0, 14), 15, False)
MsgBox "Part Details : " & vbNewLine & det
Exit Sub
MyErrorHandler:
If Err.Number = 1004 Then
MsgBox "Part not present in table."
ElseIf Err.Number = 13 Then
MsgBox "You have entered an invalid value"
ElseIf Err.Number = 429 Then
MsgBox "You're toast"
End If
メッセージボックスが表示されるはず: 品番:(データPULLED) CVまたはVA:「」 直接船:「」エラープルマクロ
など。
データは、マクロボタンとは別のシートの表から取得されます。 ボタンは単にユーザーフォームを開きます。
助けを探しています。テーブルが範囲として使用される理由は、このデータが定期的に更新され、名前付きのダイナミックレンジが機能しないためです。
ブロックのコーディングは、正しく私の謝罪をアップロードすることができませんでした。 – Zipoyt
'Table1'はどこに定義されていますか? –