View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Oldjay Oldjay is offline
external usenet poster
 
Posts: 337
Default Check for data in cell

I inserted Call Worksheet_SelectionChange and Call
Worksheet_SelectionChange(ByVal Target As Range) as the first line of my
Command Button to check for a proper selection but get an error message
"Argument not Optional"

"JLGWhiz" wrote:

Give this a shot.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 And Target.Cells.Count = 1Then
If Not IsEmpty(Target) And Target < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub



"oldjay" wrote in message
...
This code must be inserted in a sub routine so that the code doesn't
continue
if a empty cell has been selected. as written it gives an error 424
'Object
required"

"Wouter HM" wrote:

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
.



.