View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Looking at each cell when range is selected

Something like:

Dim any_filled As Boolean
any_filled = False

For Each r In Target
If IsEmpty(r.Value) Then
Else
any_filled = True
End If
Next

If any_filled Then
Call DoStep1
Else
Call DoStep2
End If


--
Gary''s Student - gsnu200800


"James" wrote:

Hi everyone, probably an easy question but i dont know how to go about this.
If i select a range of cells manually how can i write a piece of code that
will look at each cell in that selected range and see if it is blank or has
text in it? any help would be much appreciated. thanks

what ive already got :

Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo Exit_Error:
If Target.Interior.ColorIndex = 36 Then
If target.cells.count 2 then
' LOOK IN EACH CELL
'if one or more cells in target < "" then
'Do Step1
'elseif all cells in target = "" then
'Do Step 2
'end if
end if
end if