Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
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
Insert selected cell value into next cell in range that is empty Guy[_2_] Excel Worksheet Functions 6 January 3rd 09 10:08 PM
How do I activate the next cell in a selected range? Rubble Excel Programming 8 August 23rd 07 12:22 AM
Find the last cell in a selected range? J@Y Excel Programming 6 June 15th 07 07:25 PM
Does the selected cell have a range name? Bill[_41_] Excel Programming 5 March 19th 07 08:02 PM
Determining Range of selected cell [email protected] Excel Programming 2 December 5th 06 06:49 AM


All times are GMT +1. The time now is 09:38 PM.

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

About Us

"It's about Microsoft Excel"