ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Requiring data in certain cells (https://www.excelbanter.com/excel-worksheet-functions/162824-requiring-data-certain-cells.html)

jerminski73

Requiring data in certain cells
 
I have a sheet that has fields that need data to be entered into, If no data
is entered then the rest of the sheet is useless. Is there a way to pop up a
"validation" type box that will stop any forward entry until these cells have
new or different data entered? I already have basic data in these fields but
want the data to be changed in order to continue.

Thank you

vezerid

Requiring data in certain cells
 
Assuming the cells you want to have mandatory input are A1, B8 and G9.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,B8,G9")) Is Nothing Then
Application.EnableEvents = False
If Range("A1") = "" Or Range("B8") = "" Or Range("G9") = "" Then
Target = ""
MsgBox "you cannot enter a value unless ALL cells A1, B8 and G9
are filled"
End If
Application.EnableEvents = True
End If
End Sub

To install: Right click on the sheet tab. Choose View Code...
Paste the above code in the VBA IDE code window for the sheet.

HTH
Kostis Vezerides

On Oct 19, 6:22 pm, jerminski73
wrote:
I have a sheet that has fields that need data to be entered into, If no data
is entered then the rest of the sheet is useless. Is there a way to pop up a
"validation" type box that will stop any forward entry until these cells have
new or different data entered? I already have basic data in these fields but
want the data to be changed in order to continue.

Thank you




jerminski73

Requiring data in certain cells
 
Thanks for your previous post, with a few modifications I got the error
message to pop up, however something is still incorrect... The message
appears whether or not the address info is in C5:C8.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C5:C8")) Is Nothing Then
Application.EnableEvents = False
If Range("C5:C8") = "" Then Target = ""
MsgBox "To continue ALL ADDRESS INFO MUST BE ENTERED"
End If
Application.EnableEvents = True
End Sub


All times are GMT +1. The time now is 01:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com