Data Validation

  • Thread starter Thread starter Vijaya
  • Start date Start date
V

Vijaya

I want to do data validation such that if any data is entered in Cell A1 than
Cell A2 cannot be left blank. is it possible
 
Dear Vijaya

From menu Data|Validation|
Select the validation criteria|Custom
Enter formula
Uncheck 'Ignore Blank'

If this post helps click Yes
 
Oops..If your data cannot be defined you can use the below code to validate
this before Save. If you are new to macros set the Security level to
low/medium in (Tools|Macro|Security). 'Launch VBE using short-key Alt+F11. On
the left treeview double click 'This Workbook '. Drop down and select
BeforeSave event. Paste this code. Save.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Trim(Worksheets("Sheet1").Range("A1")) <> "" Then
If Trim(Worksheets("Sheet1").Range("A2")) = "" Then
Worksheets("Sheet1").Range("A2").Activate
MsgBox "This cell cannot be blank"
Cancel = True
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top