Forum Discussion
Seaneboy2020
Oct 27, 2020Copper Contributor
DATA VALIDATION - DON'T ALLOW BLANK CELLS
Hello, I'm trying to create a data validation error message, where by the message will appear when the user leaves a certain cell blank. I want the user to only be able to enter text within the r...
NikolinoDE
Oct 27, 2020Gold Contributor
With permission from everyone involved, I also have three lines of VBA here.
Private Sub Worksheet_Change (ByVal Target As Range)
If Target.Address <> "d2" and Range ("d2") = "" Then msgBox "Blablabla please"
Range ("d2"). Select
end sub
You have to enter this directly in the worksheet:
ALT + F11 to insert VBA
-> right mouse button click on the table tab (eg "Sheet1")
-> Select "Show code"
-> copy in the code
-> Close VBA editor - done
However, the warning only comes when you exit the editing mode of any cell in the worksheet.
Of course you have to adjust "d2" and "blah blah" 🙂 ... or leave out the "'" sign.
Private Sub Worksheet_Change (ByVal Target As Range)
If Target.Address <> "d2" and Range ("d2") = "" Then msgBox "Blablabla please"
Range ("d2"). Select
end sub
You have to enter this directly in the worksheet:
ALT + F11 to insert VBA
-> right mouse button click on the table tab (eg "Sheet1")
-> Select "Show code"
-> copy in the code
-> Close VBA editor - done
However, the warning only comes when you exit the editing mode of any cell in the worksheet.
Of course you have to adjust "d2" and "blah blah" 🙂 ... or leave out the "'" sign.
Hope I was able to help you.
I wish you continued success with Excel (the coolest invention since chocola... uh ... Microsoft! :-)))
And…Please keep asking here - I just taught myself Excel with the help of this forum...nearly :).
Nikolino
I know I don't know anything (Socrates)
- Seaneboy2020Oct 27, 2020Copper Contributor