dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,375
- Office Version
- 365
- 2016
- Platform
- Windows
I have a sub to enter a purchase order number against every instance of a request number. The procedure works perfectly, but it doesn't let you know if you have entered the wrong request number. This will be known if the request number does not exist on the spreadsheet. What code do I need to add to check if the request number exists in the spreadsheet and let the user know if it doesn't?
This is the sub that works but without letting the user know if the request number doesn't exist.
This is the sub that works but without letting the user know if the request number doesn't exist.
VBA Code:
Sub UpdateEverySheet() '(Req As Range, PO As Range)
Dim Sh, ws As Worksheet, Cel As Range, ReqRng As Range
Dim Req As Range, PO As Range
Set Req = Cells(18, 2)
Set PO = Cells(20, 2)
If UCase(PO) = "X" Then PO = ""
For Each Sh In Array("January", "February", "March", "April", "May", "June", _
"July", "August", "September", "October", "November", "December", "Cancellations")
Set ws = Sheets(Sh)
Set ReqRng = ws.Range("C4", ws.Range("C" & Rows.Count).End(xlUp))
For Each Cel In ReqRng
If Val(Cel) = Val(Req) Then Cel.Offset(, -1) = PO
Next Cel
Next Sh
End Sub