+ Reply to Thread
Results 1 to 5 of 5

UserForms Loop Code

  1. #1
    Registered User
    Join Date
    12-05-2011
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    3

    UserForms Loop Code

    Hi all,

    I've got a Userform which has several CheckBoxes which users can select. When the users click OK on the Userform a macro runs and does the same copy and paste function on the selected sheets. Effectively, the checkboxes relate to a different tab in the sheet, so if the users select checkbox 1 and 3 then the macro runs on Sheet1 and Sheet3.

    Now, I have a code which checks each Checkbox in turn and if it is true it selects the appropriate tab and runs the Copy and Paste function.

    What I need help with is I want it to run this as a loop to perform the same function(mainly becasue in the code provided below I only have 3 sheets but in reality I have many)

    Please Login or Register  to view this content.
    I'm not very good with loops but I want it to work along the lines of

    For each checkbox in the userform
    If it is checked then go to the corresponding tab and perform the macro
    Then move on to the next checkbox
    Repeat until all checkboxes have been checked

    I hope this is clear and thanks in advance for your help

    Cheers,

    Pocklove
    Last edited by pocklove; 12-08-2011 at 01:28 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: UserForms Loop Code

    Something like this...

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-05-2011
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: UserForms Loop Code

    Thanks Andy,

    My apologies though, in my spreasheet the tabs aren't called Division 1, Division 2 etc (Sorry for misleading you), they relate to different divisions of the organisation, such as HR, Finance, Income etc

    Would it be possible to tweak this to take those names into consideration?

    Many thanks,

    Pocklove

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: UserForms Loop Code

    A complete guess as I have no idea what sheets are called and how they relate to the controls.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-05-2011
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: UserForms Loop Code

    Thanks Andy, thats worked a treat. I had to change the names of the checkboxes back to CheckBox1 etc but its all sorted.

    Thanks for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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