+ Reply to Thread
Results 1 to 2 of 2

Use a variable to increment a variable name

Hybrid View

TravelByFireworks Use a variable to increment a... 09-21-2018, 05:19 PM
Fluff13 Re: Use a variable to... 09-21-2018, 06:02 PM
  1. #1
    Registered User
    Join Date
    01-19-2018
    Location
    Michigan, USA
    MS-Off Ver
    2016
    Posts
    9

    Use a variable to increment a variable name

    Hello,

    Not sure this is possible, but if it is I'm hoping someone here can tell me how.

        Dim fn As String
        i = 1
        For Each Resource In Range("Resources")
            Resource.Value = UCase(Resource.Value)
            fn & i = Resource.Value
            Debug.Print Resource.Value
            i = i + 1
        Next Resource
    
        Person.Add fn(i)
    where fn(i) becomes fn1, fn2, fn3, etc depending on how may first names are in named range Resources

    Thank you

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,724

    Re: Use a variable to increment a variable name

    You could do something like
       ReDim fn(1 To Range("Resources").Count) As String
    
        i = 1
        For Each Resource In Range("Resources")
            Resource.Value = UCase(Resource.Value)
            fn(i) = Resource.Value
            Debug.Print Resource.Value, fn(i)
            i = i + 1
        Next Resource

+ 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. Increment Variable with Loop
    By Redled89 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2017, 06:22 PM
  2. implement variable increment in VB Code
    By invendis in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-21-2016, 08:46 AM
  3. vba code to increment item sold on a popularity column with 3 variable
    By chubbychub in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-23-2016, 11:28 PM
  4. Using vba to increment a variable
    By TRLWNC in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-14-2015, 01:05 PM
  5. increment row number using variable
    By jagadeesh.rt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2015, 07:17 AM
  6. Increment Time variable reference cell from known range
    By Mudhafar.M in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2013, 06:38 PM
  7. Increment Variable from User Form Selection
    By jonhfl in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-01-2010, 11:29 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