Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JV JV is offline
external usenet poster
 
Posts: 22
Default Selecting a Range

Dim cell As Range
For Each cell In Range("a3:a250")
If InStr(cell, "Trex") Then
cell.Offset(0, 0).EntireRow.Select
End If
Next
Above works but now I want to make it highlight in addition to the row
highlighted all rows afterwards until the next time it finds "Trex" or 5
consecutive empty cells.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Selecting a Range

Sub dDD()
Dim cell As Range
Dim bFound As Boolean
Dim cnt As Long
Dim r As Range
bFound = False
cnt = 0
For Each cell In Range("a3:a250")
If InStr(cell, "Trex") Then
If Not bFound Then
Set r = cell
bFound = True
cnt = 0
Else
Range(r, cell).EntireRow.Select
Exit Sub
End If
End If
If IsEmpty(cell) Then
cnt = cnt + 1
If cnt = 5 And bFound Then
Range(r, cell.Offset(-5, 0)).EntireRow.Select
Exit Sub
End If
Else
cnt = 0
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"JV" wrote:

Dim cell As Range
For Each cell In Range("a3:a250")
If InStr(cell, "Trex") Then
cell.Offset(0, 0).EntireRow.Select
End If
Next
Above works but now I want to make it highlight in addition to the row
highlighted all rows afterwards until the next time it finds "Trex" or 5
consecutive empty cells.

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
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Selecting Used Range loric Excel Programming 4 May 1st 06 03:30 PM
Help please in selecting range dependent on another range MickJJ Excel Programming 2 January 10th 05 12:01 PM
Selecting a Range inside a range hcova Excel Programming 0 July 13th 04 03:26 PM
Help with selecting a range... Tom Ogilvy Excel Programming 0 July 22nd 03 03:36 PM


All times are GMT +1. The time now is 11:17 AM.

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"