+ Reply to Thread
Results 1 to 3 of 3

Incrementing variables in a Loop

  1. #1
    Registered User
    Join Date
    02-08-2008
    Posts
    35

    Incrementing variables in a Loop

    Hello
    I have a number of textboxes (e.g. txtamount1, txtAmount2, txtAmount3...) from a userform which are to be filled from an array (arrInput) however I don't know how large the array is before hand so I need to check to see if the array has a value in it, if it does I populate the userform textbox with it and go on to the next location in the array.
    I can acheive what I want using if statements...
    Please Login or Register  to view this content.
    I was wondering if I can do something like...
    Please Login or Register  to view this content.
    In the macro I'm making at the moment there are only 6 textboxes but I think this code would be useful for anything else I may try to write in the future.

    Thanks for any input

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Incrementing variables in a Loop

    Have you looked at the UBound function?

  3. #3
    Registered User
    Join Date
    02-08-2008
    Posts
    35

    Re: Incrementing variables in a Loop

    I hadn't previously but I had a quick look just now and I don't think it helps with what I'm trying to achieve, my fault for not explaining properly.

    There are "D" textboxes which I need to fill, and D is determined earlier in the macro.

    The crux of the question is can I increment the textboxes (txtAmount1, txtAmount2...) using something like txtAmount&CStr(D).value, so my code would look like...
    Please Login or Register  to view this content.
    Last edited by sungsam; 08-17-2011 at 11:38 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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