+ Reply to Thread
Results 1 to 2 of 2

Syntax for defining dynamic column range

  1. #1
    Registered User
    Join Date
    06-08-2005
    Posts
    67

    Syntax for defining dynamic column range

    I want to define a range of columns, but the number of columns may vary each time I run my macro.
    I have determined how many columns I have, so I need the proper syntax for the SET statement when the ending column definition can vary.

    I may have something like this...

    lastcolumn = 11 (this value will vary)

    Dim report as Range
    set report = Range ("a:" & lastcolumn) <---- what is correct syntax for this statement in this case?

  2. #2
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Syntax for defining dynamic column range

    This should work: Set report = Range(Columns(1), Columns(lastcolumn))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Defining Dynamic Selection Range in a Column
    By fpperryaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-29-2016, 03:42 PM
  2. defining and using a dynamic range
    By pavan210 in forum Excel General
    Replies: 0
    Last Post: 05-03-2011, 08:14 AM
  3. Defining dynamic range with VBA
    By inky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2008, 04:21 AM
  4. Programmatically defining dynamic range
    By TempestFyre in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2006, 02:55 AM
  5. Defining a Dynamic Range using a variable
    By Alseikhan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2006, 04:00 AM
  6. Syntax problem defining range for pivot table
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 02:55 PM
  7. [SOLVED] Defining Dynamic Range
    By Jamie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1