+ Reply to Thread
Results 1 to 4 of 4

Loop with a changing name based on the loop

Hybrid View

brucemc777 Loop with a changing name... 05-26-2014, 11:03 AM
MickG Re: Loop with a changing name... 05-26-2014, 11:10 AM
brucemc777 Re: Loop with a changing name... 05-26-2014, 01:57 PM
MickG Re: Loop with a changing name... 05-27-2014, 04:46 AM
  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Loop with a changing name based on the loop

    Oh I wish I could have provided more clear title...

    In a For-Next loop I want to place the name of a control, a checkbox, and change it with the number of loop I am on, such as if on the first loop I would have cbx01, on the second loop it would become cbx02, as in

    For intCtr = 1 to 10
         If ActiveSheet.ckb & Cstr(intCtr) & .Value = True Then
              <Do something>
         End If
    Next
    in order to loop through ckb1 through ckb10.

    Thoughts?

    Thank-you!

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Loop with a changing name based on the loop

    Try :-
    Sub MG26May33
    Dim n As Integer
    For n = 1 To 5
        If ActiveSheet.OLEObjects("CheckBox" & n).Object.Value = True Then
            '"Do Something"
        End If
    Next n
    End Sub
    Regards Mick

  3. #3
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Loop with a changing name based on the loop

    Interesting. I will have to experiment to see how this might apply to other uses. Thank-you!

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Loop with a changing name based on the loop

    You're welcome

+ 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. Changing the index of a for loop inside of the loop
    By drinkmorewine in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-03-2013, 12:19 PM
  2. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  3. Do-While loop within a do-while loop? Dealing with changing number of rows
    By Motox in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2012, 12:59 AM
  4. How can I avoid changing a loop counter within a loop?
    By broro183 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2009, 07:59 PM
  5. Advancing outer Loop Based on criteria of inner loop
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2005, 01:05 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