ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   multiple selection problem (https://www.excelbanter.com/excel-programming/278481-multiple-selection-problem.html)

XLNT

multiple selection problem
 
How can i code muliple selections say i want to select rows 3,5,7
together

like

Rows(3).select
Rows(5).select
Rows(7).select



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Ron de Bruin

multiple selection problem
 
One way

Sub test()
Range("a3,a5,a7").EntireRow.Select
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"XLNT" wrote in message ...
How can i code muliple selections say i want to select rows 3,5,7
together

like

Rows(3).select
Rows(5).select
Rows(7).select



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Tom Ogilvy

multiple selection problem
 
Use Union

for i = 3 to 7 step 2
if rng is nothing then
set rng = Rows(i)
else
set rng = Union(rng,rows(i))
Next

or

set rng = Range("A3,A5,A7").EntireRow

demo from the immediate window:
set rng = Range("A3,A5,A7").EntireRow
? rng.Address
$3:$3,$5:$5,$7:$7

so also
set rng = Range("3:3,5:5,7:7")

demo from the immediate window:
set rng = Range("3:3,5:5,7:7")
? rng.Address
$3:$3,$5:$5,$7:$7



--
Regards,
Tom Ogilvy

"XLNT" wrote in message
...
How can i code muliple selections say i want to select rows 3,5,7
together

like

Rows(3).select
Rows(5).select
Rows(7).select



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com