Hello, I have a form on a spreadsheet in Excel that someone fills out in cells. I want to make the date and time cells highlight yellow when someone forgets to fill them in and exit the sub with a message to fill in the fields.
I swear this code worked last week when I tested it before uploading so others could use. But today, I'm getting an "application-defined or object defined error."
Here is the beginning of the code. In this I set a variable for the name of the sheet (logName) and another variable for the hidden sheet where the form data is copied (masterName). There are three sheets with date and time fields in the same cells on each sheet, and I make sure the cell is the correct background color before proceeding. However, the red text below is where the code hangs up. I don't see anything wrong with my code, and as I wrote above, it worked last week.
Why is it giving me this error now? What is causing the error, and how can I fix it?
I swear this code worked last week when I tested it before uploading so others could use. But today, I'm getting an "application-defined or object defined error."
Here is the beginning of the code. In this I set a variable for the name of the sheet (logName) and another variable for the hidden sheet where the form data is copied (masterName). There are three sheets with date and time fields in the same cells on each sheet, and I make sure the cell is the correct background color before proceeding. However, the red text below is where the code hangs up. I don't see anything wrong with my code, and as I wrote above, it worked last week.
Why is it giving me this error now? What is causing the error, and how can I fix it?
Rich (BB code):
Sub save_and_print()
Application.ScreenUpdating = False
Dim logName As String
Dim masterName As String
logName = ActiveSheet.Name
If logName = "Hospital Outcome Log" Then
masterName = "Hospital Log Master"
ElseIf logName = "On Call Log" Then
masterName = "On Call Master"
Else
masterName = "MHC Master"
End If
'Check to see that the two required fields are entered.
Sheets(logName).Range("B5").Interior.Color = RGB(217, 225, 242)
Sheets(logName).Range("E5").Interior.Color = RGB(217, 225, 242)
Last edited by a moderator: