X XLNT Oct 1, 2003 #1 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
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 Oct 1, 2003 #3 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
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