Thread: cell validation
View Single Post
  #2   Report Post  
Hayeso
 
Posts: n/a
Default

Install
=========
Right click on the sheet tab and select View Code.
Paste the code below in the code window and select select
File...Close and return to Microsoft Excel.


Use
===
Select a cell
Select Tools...Macro...Macros..MarkNonBlank and press Run

To remove from cell, Select the cell and change the colour of the interior
to anything other than yellow.


Code(Paste this into the code window)
=========================
Private OldSelection As Range
Private Const NonBlankColor As Single = vbYellow

Public Sub MarkNonBlank()
Selection.Interior.Color = NonBlankColor
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim BlankCell As Boolean
BlankCell = False
If OldSelection Is Nothing Then
Set OldSelection = Me.Cells(1, 1)
End If
With OldSelection
If .Cells.Count = 1 Then
If .Interior.Color = NonBlankColor Then
If Trim(.Cells(1)) = "" Then
BlankCell = True
End If
End If
End If
End With
If BlankCell Then
OldSelection.Select
Else
Set OldSelection = Target
End If
End Sub

"srinivas sarma" wrote:


Hello

I just want to restrict user not enter a cell blank. If so he should
get an error message saying 'error'. He even should not bypass the
cell.

How to do it

Srini


--
srinivas sarma
------------------------------------------------------------------------
srinivas sarma's Profile: http://www.excelforum.com/member.php...o&userid=24834
View this thread: http://www.excelforum.com/showthread...hreadid=383852