multiple selection problem

X

XLNT

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top