+ Reply to Thread
Results 1 to 5 of 5

Using a variable name in a Range Select

  1. #1
    Forum Contributor
    Join Date
    07-03-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    139

    Using a variable name in a Range Select

    I am working on a sheet that will change the range for certain cells each time a new week rolls around. Therefore I want to enter in a variable name fore the cells to select rather than coded range.

    I.E.

    Rather than

    Please Login or Register  to view this content.
    I want to use
    Please Login or Register  to view this content.
    I am using a 52 statement CASE statement to assign the Var1 values, again I.E.

    Please Login or Register  to view this content.
    I have tried a few different methods to get this simple range select to work with a variable name with no luck at all. in the example above the code runs, but does not select anything at all, and in the example below I get a Method 'Range' of pbject_Global' failed, runtime error 1004

    Any assistance on this would be greatly appreciated.

    Thank You

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Using a variable name in a Range Select

    Range(var1).select

    ?

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Using a variable name in a Range Select

    Post your full code or your workbook. We need to see why the Vars are not getting set.

    Something like:

    Please Login or Register  to view this content.
    will work once Var1 has been set-up.
    Gary's Student

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Using a variable name in a Range Select

    Try removing the quotes around var1.

  5. #5
    Forum Contributor
    Join Date
    07-03-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Using a variable name in a Range Select

    This did it!! I could have sworn I tired this without the quotes when I first put the variables in. I must have missed something somewhere. Thank you much, sometimes it just takes another pair of eyes!!

+ 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. VBA - how to select a big range with a variable?
    By Safadinhu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2010, 03:29 PM
  2. Select a Range of (Variable) Rows
    By Loucas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2006, 08:15 PM
  3. select a variable range
    By evil baby in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2006, 04:38 PM
  4. [SOLVED] select range and put range address in variable
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2006, 09:30 PM
  5. Select a Range Through a Variable
    By GoFigure in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2005, 09:02 AM

Tags for this Thread

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