ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   not allow empty cells (https://www.excelbanter.com/excel-programming/343942-not-allow-empty-cells.html)

Maggie

not allow empty cells
 
I tried using Data, Validation for this, but couldn't get it to work. I need
to check a cell to ensure the value entered is between 0 and 60, but I also
need to prevent the user from leaving the cell blank.
--
Thank you,
Maggie

JakeyC

not allow empty cells
 
I think we need more info on how it is used.

Does the cell begin blank? And if so, when does the user confirm their
'final answer'? i.e. if they were to enter the cell, delete the
contents and enter another cell before returning to the first to
re-enter a figure, would this generate an error or be acceptable?


Gary Keramidas

not allow empty cells
 
try this pasted on the sheet code page and see if it works for you. i used
a4 in this example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Set rng = Range("a4")
If rng.Value = "" Then
MsgBox " You must enter a number"
rng.Select
End If
If rng.Value < 0 Or rng.Value 60 Then
MsgBox " you must enter a number between 0 and 60"
rng.Select
End If

End Sub

--


Gary


"Maggie" wrote in message
...
I tried using Data, Validation for this, but couldn't get it to work. I
need
to check a cell to ensure the value entered is between 0 and 60, but I
also
need to prevent the user from leaving the cell blank.
--
Thank you,
Maggie





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

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