+ Reply to Thread
Results 1 to 11 of 11

Referencing a string in a loop

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Referencing a string in a loop

    Hi All

    I have the following lines of code
    Please Login or Register  to view this content.
    How can I reference the above in a loop such as
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Referencing a string in a loop

    You can't ... at least not in VBA as it doesn't support runtime evaluation of variables by name.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    Hi cytop
    Darn so how can I reference in a loop or must it be done individually.
    Am trying to assist in this link:
    https://www.excelforum.com/excel-pro...rate-cell.html
    Last edited by sintek; 04-14-2017 at 10:44 AM.

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

    Re: Referencing a string in a loop

    Use an array.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    Thanks Norie....that will come in handy

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    Norie, How do i reference arrNum(c + 1) ' or next array meaning
    i mean if there are 3 arrays

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    What I mean is if in the array loop I want to Do something until the value in A and next row = next array

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    Not to worry, got it thanks arrNum(c + 1)

  9. #9
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Referencing a string in a loop

    If you put the code in "object based" module (sheet module, workbook module, class module, userform module) (not in "object-less" module a.k.a. standard module), you can define the variables as public at module declaration, then you can call these variables using callbyname() method :

    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,256

    Re: Referencing a string in a loop

    Great, thanks karedog, that's gonna come in handy.

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Referencing a string in a loop

    You are welcome, glad I can help.

    Regards

+ 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. Referencing Multiple Cells Within A Loop (VBA)
    By daveh21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2015, 11:27 AM
  2. Loop through a string and find the character/string need
    By dluhut in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-15-2014, 11:51 AM
  3. Loop through all occurrences of a string within a string
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2013, 10:16 AM
  4. Referencing an array within a For Next loop. Please help?
    By jinxtt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2012, 05:06 PM
  5. referencing cell from different sheets in a loop
    By abgis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2007, 09:40 AM
  6. Referencing variable Range in a loop
    By Samirkc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2006, 07:55 AM
  7. Referencing variable in a loop
    By JeffMelton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2006, 11:25 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