+ Reply to Thread
Results 1 to 4 of 4

Declare variables within a loop?

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    Östersund, Sweden
    MS-Off Ver
    Office 365 ProPlus
    Posts
    2

    Declare variables within a loop?

    I´d like to dim as many variables, varX, as the cell A1 says. Let´s say the value in A1 = 3.

    Something like this:
    Please Login or Register  to view this content.
    The use for these varX variables is to keep track of a couple of For loops.
    From the beginning of the code, I don´t know how many loops I need.
    The final result I´m looking for is:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Declare variables within a loop?

    There is more than just control variable which is to be dynamic - you will need a dynamic number of for-next loops.

    I doubt if you can do it. so may be rethink your algorithm.

    It seems that a recurrence algorithm with the current number of control variable passed as one of the parameters shall be an answer .
    Best Regards,

    Kaper

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Declare variables within a loop?

    An example of such approach from other forum - unfortunately in Polish: http://www.excelforum.pl/viewtopic.php?p=205542 (there are similar threads here, but unfortunately "Search" at our forum is currently not working too well):

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-26-2012
    Location
    Östersund, Sweden
    MS-Off Ver
    Office 365 ProPlus
    Posts
    2

    Re: Declare variables within a loop?

    Thank you Kaper for your answers.

    I guess you´re right, I´ll check in to that.

+ 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] Declare 2 variables instead range
    By fulldeen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-10-2014, 08:54 AM
  2. [SOLVED] How do you declare several variables?
    By bananajelly in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-22-2014, 05:43 PM
  3. How do you declare several variables?
    By bananajelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2014, 11:55 AM
  4. [SOLVED] How to declare variables
    By nav505 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2013, 01:25 PM
  5. Why declare variables
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2009, 12:03 PM
  6. [SOLVED] How to efficiently declare variables
    By Jeff in forum Excel General
    Replies: 2
    Last Post: 06-29-2006, 09:00 AM
  7. [SOLVED] declare Variables
    By Lee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2005, 05:05 PM

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