Hi all,
A little back-story - our company keeps track of purchase orders via an excel spreadsheet (each row contains: date, po. number, tech name, part name, job code number or job name, cost...). In column C we note the name of our technician, and in column G we note the job code number or job name. Unfortunately we've been having an issue with some staff not filling in the job code number/name, which is a huge issue for billing/invoicing purposes.
I am looking for some help in writing VBA code that will make an empty cell in column G require a value before closing/ saving the workbook if a text value exists in the same row in column C. Ideally any user who has left the value in column G blank will be prompted with a message box or something similar when they try to close the workbook - and ideally they will be unable to save or close it at all unless a value exists in that G cell.
This is the first time I've attempted using VBA, as I often just stick with conditions and if statements. I have included what i have written so far, but even that took about half an hour
Any help you may be able to offer would be amazing and super appreciated.
Cheers!
Kym
Function reqd_cell_data() As Boolean
If (IsText(C)) And (IsEmpty(G)) Then
MsgBox Prompt:="JOB CODE REQUIRED", Buttons:=vbOKOnly + vbInformation
End Function
PS, if there is also a way for the message box to include the cell that triggered the prompt (it'll change every time as the prompt is triggered) that would be FANTASTIC. (IE. "JOB CODE REQUIRED - G89")
Bookmarks