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.
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

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:

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,211
Messages
5,509,853
Members
408,757
Latest member
Jamarr123

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top