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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select non-adjacent cells in a Range in Excel

Status
Not open for further replies.

donishere

Programmer
May 7, 2002
101
How do I select non-adjacent cells in Excel? Do I use the Range function?

thanks,
don
 
Hi Don,

This should do it...

Sub Selection_Disjointed_Cells()
Range("a1:a10,G21:G24,D20:D23").Select
Selection.Name = "test"
End Sub

The last row assigns the range name "test" to all these disjointed ranges. Then you can more easily reference this collection of ranges by just the one name.

If you can also reference the individual ranges by a Range Name, then you should also do so - i.e. assign the range names beforehand. Anytime one can eliminate "hard-coding" it's naturally preferable.

Hope this helps. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top