Hello,
I have following macro which on Error will resume to next.
Now I want to display a message box if an error is found and after exit SUB
Message box( "Part number" & "PN" & "not found. Please define packaging details")
By PN should be displayed the part number that is not found.
Thank you!
Madi
I have following macro which on Error will resume to next.
Now I want to display a message box if an error is found and after exit SUB
Message box( "Part number" & "PN" & "not found. Please define packaging details")
By PN should be displayed the part number that is not found.
VBA Code:
Sub Vlookup()
Dim Volume As Worksheet
Dim Packaging As Worksheet
Dim PN As Long
Dim Pcs As Long
Dim x As Variant
Dim dataRNG As Range
Set Volume = ThisWorkbook.Worksheets("Volume per shipment")
Set Packaging = ThisWorkbook.Worksheets("Packaging details")
PN = Volume.Range("A" & Rows.Count).End(xlUp).Row
Pcs = Packaging.Range("A" & Rows.Count).End(xlUp).Row
Set dataRNG = Packaging.Range("A2:G" & Pcs)
For x = 2 To PN
On Error Resume Next
Volume.Range("D" & x).Value = Application.WorksheetFunction.Vlookup( _
Volume.Range("A" & x).Value, dataRNG, 7, 0)
Next x
End Sub
Thank you!
Madi