Sub MyReplaceMacro()
Dim partNum As String
Dim batch As String
partNum = InputBox("Enter the part number you wish to search for")
' See if part number found in column A on "Batch" sheet
Sheets("Batch").Activate
On Error GoTo not_found
Columns("A:A").Find(What:=partNum, After:=Range("A1"), LookIn:=xlFormulas _
, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
On Error GoTo 0
' Prompt for new batch number
batch = InputBox("Enter the new batch number")
ActiveCell.Offset(0, 1) = batch
Exit Sub
'Error handling if part number not found
not_found:
MsgBox "Cannot find part number " & partNum & " on Batch sheet", vbOKOnly, "ERROR!"
End Sub