As you can see in the attached spreadsheet, there are two tabs with data: By Major and By Concentration. Now if someone enters a number to any of the three cells H18, I18, or M18 in the By Major tab, I want to prevent the person from closing the spreadsheet without entering numbers to all of the columns C, E, F, G in the By Concentration tab for at least one row. For example, if someone has entered "6" to M18 to the By Major tab, I want the person to also enter numbers to C, E, F, G in the By Concentration tab for at least one row (e.g., row 5). If the person tries to close the spreadsheet without entering the required numbers, I want a message saying he needs to enter the required numbers.
It is my final goal above, and now I even can't have the basic of the basic working. I have the code below, and apparently something is wrong. If someone could please help me, I'd greatly appreciate it.
Thank you very much in advance!
![]()
Private Sub Workbook_BeforeClose(Cancel As Boolean) If Len(Trim(Sheets("Sheet1").Range("H18").Value)) > 0 Then If (Trim(Sheets("Sheet4").Range("E5").Value)) = 0 Then prmt = MsgBox("Please enter numbers to column C, E, F, G in Sheet2 to at least one row.", vbCritical, "Name Required") End If Cancel = True End If End Sub
Bookmarks