Hi everyone, I have a macro that working great that is activated by pressing a button. I want to add a message box at 2 different locations but when i do it, im getting errors. here is the code:
You can see my 2 message boxes at the top of the code. I want for them to pop up if either of these 2 conditions are met to tell the operator why there is an error. If the msg box lines are not there, the code works fine.
Any suggestions? thanks
Code:
Sub ScanLHQR()
'
If Sheets("sheet1").Range("F5").Value = "Bad" Then
Msg Box "This Code has already been scanned"
Exit Sub
If InStr(1, (Range("c8").Value), "P3041096") > 0 Then
MsgBox "This is the incorrect Label"
Exit Sub
Range("C8").Copy
Sheets("LHLabelNumbers").Select
On Error Resume Next
Dim xCell As Range
For Each xCell In ActiveSheet.Columns(1).Cells
If Len(xCell) = 0 Then
xCell.Select
Exit For
End If
Next
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Scan").Select
Range("C8").ClearContents
End Sub
You can see my 2 message boxes at the top of the code. I want for them to pop up if either of these 2 conditions are met to tell the operator why there is an error. If the msg box lines are not there, the code works fine.
Any suggestions? thanks