+ Reply to Thread
Results 1 to 2 of 2

<Question> How to use Variables to define a Range of cells.

  1. #1
    Registered User
    Join Date
    09-16-2015
    Location
    Places
    MS-Off Ver
    2013
    Posts
    20

    <Question> How to use Variables to define a Range of cells.

    Hi all,

    Hopefully a very simple question.

    Please Login or Register  to view this content.
    The above line of code takes cells "A1" to "C1" and connects them, as if they are a chart header, to the cells specified by the variables NumberOfRows and NumberOfColumns.

    However, since NumberOfColumns is a variable, the user can specify, say, 6 columns. The problem is that because I'm forced to specify cells "A1:C1" that outputs a chart with only 3 column headers, but 6 columns.

    The question is:

    How can I express the part of code Range("A1:C1") with "A1:C1" expressed as variables? This would mean I could place a variable there instead of defining specific cells, so that the number of column headers would adapt to the user-specified number of columns.

    I'm sure this is probably very simple to do, but I'm very new to Excel VB Code so haven't encountered this before.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: <Question> How to use Variables to define a Range of cells.

    maybe so
    Please Login or Register  to view this content.

+ 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] Variables to define range - should be easy?
    By BremhillBob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2014, 03:13 PM
  2. How to define a range of cells, by two variables?
    By Skipperron in forum Excel General
    Replies: 1
    Last Post: 11-08-2011, 06:09 PM
  3. Using variables to define a range
    By Aelyn in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2011, 04:27 AM
  4. need help to define a range using two variables
    By dschmitt in forum Excel General
    Replies: 1
    Last Post: 03-15-2010, 08:31 PM
  5. need help to define a range using two variables
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2010, 08:14 AM
  6. [SOLVED] Using variables to define a range of cells?
    By Matt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2006, 04:45 PM
  7. How to use variables to define range
    By Dolemite in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-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