Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multiple row selection

Hello,

Is there a way to select multiple rows given a certain
criteria is met? I have the following code which only
selects one row at a time, but I would like the code to
select all the rows for which the cell in the Range is
equal to "Cat".

Dim R As Range, Cel As Range
Set R = Range("A8:A27")
Set Cel = Range("A8:A27")
For Each Cel In R
If Cel.Value = "Cat" Then _
Cel.EntireRow.Select
Next Cel

Thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Multiple row selection

Dim R As Range, Cel As Range
dim AllCat as Range
Set R = Range("A8:A27")
Set Cel = Range("A8:A27")
set allcat = nothing

For Each Cel In R
If Cel.Value = "Cat" Then
if allcat is nothing then
set allcat = cel
else
set allcat = union(cel, allcat)
end if
end if
next cel

if allcat is nothing then
'nothing to select
else
allcat.entirerow.select
end if


Minh wrote:

Hello,

Is there a way to select multiple rows given a certain
criteria is met? I have the following code which only
selects one row at a time, but I would like the code to
select all the rows for which the cell in the Range is
equal to "Cat".

Dim R As Range, Cel As Range
Set R = Range("A8:A27")
Set Cel = Range("A8:A27")
For Each Cel In R
If Cel.Value = "Cat" Then _
Cel.EntireRow.Select
Next Cel

Thank you in advance.


--

Dave Peterson

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
multiple selection AND Excel Discussion (Misc queries) 9 February 13th 09 07:40 PM
multiple selection.... AND Excel Worksheet Functions 1 February 13th 09 12:35 AM
ListBox Multiple Selection Todd Huttenstine Excel Programming 1 April 26th 04 06:15 PM
Multiple Col. Selection David Fixemer Excel Programming 6 February 17th 04 11:10 PM
multiple selection Michalll Excel Programming 3 December 3rd 03 12:58 AM


All times are GMT +1. The time now is 07:37 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"