L
L. Howard Kittle
Hello Excel users and Experts,
Excel 2002 SP3
I'm stumped on error handling in this code. If there is no number entered
in the Input box I get a type mismatch error message. Have tried "If j is
nothing exit sub", and "on error resume next" but it keeps slapping me
around! If you enter a number that is not in the list in column A then I
don't get the error but want to do a message box saying the number did not
exist in Col A. It's kicking my butt on that too!
Sub TransferIt()
Dim i As Long
Dim Rng As Range
Dim c As Range
Dim j As Long
i = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A2:A" & i)
j = InputBox("Please enter the job" & vbCr & _
"number you wish to" & vbCr & "print a job card for")
For Each c In Rng
If c.Value = j Then
c.Resize(1, 7).Copy Sheets("Sheet2"). _
Range("G100").End(xlUp).Offset(1, 0)
End If
Next
End Sub
Thanks for your help.
Regards,
Howard
Excel 2002 SP3
I'm stumped on error handling in this code. If there is no number entered
in the Input box I get a type mismatch error message. Have tried "If j is
nothing exit sub", and "on error resume next" but it keeps slapping me
around! If you enter a number that is not in the list in column A then I
don't get the error but want to do a message box saying the number did not
exist in Col A. It's kicking my butt on that too!
Sub TransferIt()
Dim i As Long
Dim Rng As Range
Dim c As Range
Dim j As Long
i = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A2:A" & i)
j = InputBox("Please enter the job" & vbCr & _
"number you wish to" & vbCr & "print a job card for")
For Each c In Rng
If c.Value = j Then
c.Resize(1, 7).Copy Sheets("Sheet2"). _
Range("G100").End(xlUp).Offset(1, 0)
End If
Next
End Sub
Thanks for your help.
Regards,
Howard