Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2005, 07:16 AM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select multiple ranges....

Hello.

I haven't been doing this for long time, and now I have a problem.

This code works fine for me:

Range("B8:C10,H8:H10").Select

but I want to have it in this format:

Range(Cells(8, 2), Cells(10, 3), Cells(8, 8), Cells(10, 8)).Select

but that doesn't work.

Please help and thanks in advanced.

/Mats
 
Old June 9th, 2005, 07:26 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sub myMultiRangesub()


    Dim r1, r2, myMultipleRange As Range
    Set r1 = Range(Cells(8, 2), Cells(10, 3))
    Set r2 = Range(Cells(8, 8), Cells(10, 8))
    Set myMultipleRange = Union(r1, r2)
    myMultipleRange.Select

End Sub

Alternatively simplify it with

Union(Range(Cells(8, 2), Cells(10, 3)), Range(Cells(8, 8), Cells(10, 8))).Select


Cheers

Matt
 
Old June 9th, 2005, 08:01 AM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, it worked fine. :)

/Mats





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple select box vinikz Java Databases 1 September 4th, 2007 07:21 AM
multiple select problem austinf HTML Code Clinic 0 June 19th, 2006 11:54 PM
Set multiple variables with one Select? djuricd SQL Server 2000 2 June 14th, 2004 08:08 AM
multiple select--Urgent muralikeane Classic ASP Databases 3 May 12th, 2004 07:00 AM
Grant SELECT on multiple tables oidhche SQL Server 2000 3 June 16th, 2003 06:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.