LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.misc
CLR
 
Posts: n/a
Default Cell can not be blank

Hi Todd.....

Well, this one seems to do the job for four cells.........whatcha think?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Range("A1").Value < "" Then
Range("a1").Select
MsgBox "Cell A1 must contain a value"
Else
If Not Range("b1").Value < "" Then
Range("b1").Select
MsgBox "Cell B1 must contain a value"
Else
If Not Range("c1").Value < "" Then
Range("c1").Select
MsgBox "Cell C1 must contain a value"
Else
If Not Range("d1").Value < "" Then
Range("d1").Select
MsgBox "Cell D1 must contain a value"
End If
End If
End If
End If
End Sub



"Todd" wrote in message
...
That's what I tried and when you tab over to cell b1 it gives you the

mesage
box first before leaving the cell. I need it to only come up if you leave
the cell.

"CLR" wrote:

Maybe something like this, just for two cells...could be expanded

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Range("a1").Value < "" Then
MsgBox "cant do that"
Range("a1").Select
ElseIf Not Range("b1").Value < "" Then
MsgBox "cant do that"
Range("b1").Select
End If
End Sub

hth
Vaya con Dios,
Chuck, CABGx3


"Todd" wrote:

Is there any way to get this to work for 3 other cells. When I put in
another if statement and go to my worksheet when I change to the next

cell
where my new if statement goes with, the message box pops up as soon

as the
cell is activated. I would like for it to activate when the cell is

left if
it is blank. Any ideas. The first code is exatly what I am looking

for.

"CLR" wrote:

Maybe this..........

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Range("a1").Value < "" Then
MsgBox "cant do that"
Range("a1").Select
Else
End If
End Sub


Vaya con Dios,
Chuck, CABGx3



"Todd" wrote:

Is there any way to force a user to input data in to a cell and if

they move
off when it is blank it will prompt them to input data. I have

tried the
validation rules but it does not stop blank cell.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
Blank (empty) cell always equal to 0?? ulfah Excel Discussion (Misc queries) 3 February 1st 06 04:55 PM
Setting Purely BLANK Cell yokato95 Excel Worksheet Functions 4 August 18th 05 04:43 PM
Replace null string with blank cell gjcase Excel Discussion (Misc queries) 2 August 9th 05 02:13 PM
Look for change next blank cell in Range Nigel Bennett Excel Worksheet Functions 1 March 13th 05 09:45 PM


All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"