Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking at each cell when range is selected
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert selected cell value into next cell in range that is empty | Excel Worksheet Functions | |||
How do I activate the next cell in a selected range? | Excel Programming | |||
Find the last cell in a selected range? | Excel Programming | |||
Does the selected cell have a range name? | Excel Programming | |||
Determining Range of selected cell | Excel Programming |