Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Range Selection by variable

Status
Not open for further replies.

DreamerZ

Programmer
Joined
Jul 11, 2001
Messages
254
Location
US
If your range selection is:
Code:
Range("S25,F2,H14").Select
The cells are selected individually like you've clicked on each one while holding the Control key. All 3 cells are looked at like Cell 1.

How can you do that with variables?
Code:
Range(cellrange1,cellrange2).Select
doesn't work. Each variable is an Address ($A$1) and is viewed by the Range as Cell 1, Cell 2 so it's like you've selected the first cell, hit Shift and then selected the second cell so it selects the series, not the individual cells.

Thoughts? Thx.


DreamerZ
simplesolutions@prodigy.net
[ignore][/ignore]
 
Hi,
Code:
Set rng1 = Cells(25, "S")
Set rng2 = Cells(2, 6)
Set rng3 = Cells(14, 8)
Set rng4 = Application.Union(rng1, rng2, rng3)
rng4.Select
Keep in mind that in MOST cases, you need not nor should not select/activate since that slows code processing faq707-4105 How Can I Make My Code Run Faster?

:-)

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884

Skip,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top