Hey guys,
So I made this macro that will prompt the user for an item number input, then a unit price input and then it will find the item number in column A and go over to column C and input the unit price (based on user input). My code keeps getting an error at the first if statement and I don't know why, any help is appreciated! (I'm new to VBA, so bear with me lol).
Sub Add_Price_Click()
Dim ItemNo As Variant, UnitPrice As Variant, SearchRng As Range
ItemNo = Application.InputBox(Prompt:="Enter an Item Number:", Title:="Add Unit Price")
If ItemNo Is Nothing Then
MsgBox ("Please enter an item number and try again.")
Exit Sub
End If
Set SearchRng = Range("A:A").Find(ItemNo, "A4", xlValues)
If SearchRng Is Nothing Then
MsgBox ("Item not in database.")
Exit Sub
End If
UnitPrice = Application.InputBox(Prompt:="Enter the Unit Price:", Title:="Add Unit Price")
If UnitPrice Is Nothing Then
MsgBox ("Please enter a unit price and try again.")
Exit Sub
End If
SearchRng.Offset(0, 2) = UnitPrice
End Sub
Bookmarks