Data Validation for empty cell

dan1130

New Member
Joined
Aug 5, 2010
Messages
6
Need your help please..

I have a form that requires an approval. The problem is that the approval is always missed.

I want to place a validation if cell is empty and also have the error alert pop up.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Hi and welcome to the board!!!
You can use a BeforeSave event to check that cell. An example
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheet1.Range("$A$1") = "" Then
   MsgBox "Approval required"
   Cancel = True
   Sheet1.Range("$A$1").Select
End If
End Sub
Place this in the ThisWorkBook module!!
HTH
lenze
 

dan1130

New Member
Joined
Aug 5, 2010
Messages
6
Hi Lenze,

Thanks for the quick reply but that's way over my head.

I do not know where to place the code. I'm assuming it's the VB editor.

I don't mind trying it just do no know where to place it.

Thanks
Daniel
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Open the VBE(ALT+F11). You should see the Project Explorer on the left!! If not, enter CTRL+R to open it. DoubleClick on the module "ThisWorkBook" and paste the code I posted in the white panel. Change the SheetNanme and cell reference for your desired "Check Off" cell!I t's really quite easy. The code will run whenever you save the file. You may want to go with a sightly different code
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheet1.Range("$A$1") = "" Then
MsgBox "Approval required"
Cancel = True
Sheet1.Range("$A$1").Select
End If
End Sub
It might be less confusing for making backup saves

Good luck
lenze
 

dan1130

New Member
Joined
Aug 5, 2010
Messages
6
Hi Lenze,

I tried it this morning and I get a run time error "424" message. I click debug and it highlights the bolded line below.

Cell F426 is merged, so I took the merge off and I still get the message. I have 3 tabs in this workbook and this approval box is in the tab named "Invoice".

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Invoice.Range("$F$426") = "" Then
MsgBox "Approval required"
Cancel = True
Invoice.Range("$F$426").Select
End If
End Sub
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
In my example, I used the CodeName for the sheet. You are trying to use the "Assigned Name" It's a slightly different syntax!
Rich (BB code):
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheets("Invoice").Range("$F$426") = "" Then
MsgBox "Approval required"
Cancel = True
Sheets("Invoice").Range("$F$426").Select
End If
End Sub
See my discussion on Sheet Names here

lenze<!-- / message -->
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,133,325
Messages
5,658,162
Members
418,430
Latest member
Chlwls808

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top