+ Reply to Thread
Results 1 to 4 of 4

Dynamically named variables

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Dynamically named variables

    Hi there

    Is there anyway to dynamically create and name variables with part of the name given from the value from another variable?

    Like make a variable called CopyColumn4, where the number 4 comes from a variable called lrow that contains the value 4?

    For instance, lets say I now define some variables manually, like below:
    Please Login or Register  to view this content.
    Could I do that in some way with a For statement or any other dynamic way?

    I was guessing it could be done with something like below, but its not accepting the syntax:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Dynamically named variables

    Sorry but you can't dynamically create variables in that way in VBA.

    Not sure what you are doing but have you considered using an array?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Dynamically named variables

    Edited: Oh didnt look through you code properly, thought you were just pasting mine - Ill look into it and try it out - thanks a lot.
    Last edited by Imbizile; 01-14-2018 at 06:29 PM.

  4. #4
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Dynamically named variables

    Just tried it and it was exactly what I was after. Really appreciate it! Cheers

+ 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. Build named variable dynamically
    By sumdumgai in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 08-16-2016, 09:09 AM
  2. How to activate a dynamically-named workbook in VBA
    By oddinho2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2013, 02:18 PM
  3. [SOLVED] Dynamically re-name a Named Range
    By jeremytapkeg in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-10-2013, 06:46 PM
  4. [SOLVED] Trying to save worksheet as a dynamically named PDF
    By RebeccaEllis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2012, 06:31 PM
  5. How to dynamically-parse text from webpage to variables?
    By amateurmetheus in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-28-2010, 11:54 AM
  6. Dynamically naming variables
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2010, 04:26 PM
  7. Dynamically changing named range
    By jd316632 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2009, 10:58 AM

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