+ Reply to Thread
Results 1 to 9 of 9

How to loop through controls

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    How to loop through controls

    Hello forum

    A userform with this naming convention

    ctrl1 ctrl2 ctrl3

    aCtrl1 aCtrl2 aCtrl3 aCtrl4 aCtrl5
    bCtrl1 bCtrl2 bCtrl3 bCtrl4 bCtrl5
    cCtrl1 cCtrl2 cCtrl3 cCtrl4 cCtrl5
    dCtrl1 dCtrl2 dCtrl3 dCtrl4 dCtrl5

    cmdsave

    there twleve such lines up to kCtrl

    All I need to do is to transfer the values of these controls to my worksheet starting from A2 to H2 by clicking on cmdsave button I want the values of the first 3 controls(ctrl1,2,3) to be repeated with the bellow 12 lines controls
    means the values of ctrl1,2 ,3 should go to column A to column C and the other 12 lines of controls's values should go to columnD to columnH (all the 12 lines are not neccessarily be filled .these can be less than12

    How can these controls be looped in order to transfer their respective values to w/sheet?.

    I will be greatfull to any help.

    Best Regards
    Imran Bhatti
    Teach me Excel VBA

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to loop through controls

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: How to loop through controls

    Something else to play with:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: How to loop through controls

    the values of ctrl1,ctrl2,ctrl3 are going to the their destination (in a2,b3,c3) columns. but the values of the bellow line i.e
    aCtrl1 aCtrl2 aCtrl3 aCtrl4 aCtrl5
    bCtrl1 bCtrl2 bCtrl3 bCtrl4 bCtrl5
    cCtrl1 cCtrl2 cCtrl3 cCtrl4 cCtrl5
    dCtrl1 dCtrl2 dCtrl3 dCtrl4 dCtrl5
    are not reaching their. ok..let me remove the data and send the blank file.
    Last edited by ImranBhatti; 11-21-2016 at 12:14 AM.

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: How to loop through controls

    here is the file

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: How to loop through controls

    It seems there is some problems uploading my file. I tried repeatedly but not getting attached.

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

    Re: How to loop through controls

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    If posting code please use code tags, see here.

  8. #8
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: How to loop through controls

    Excel file is not uploading but I have attached the snapshots of both the userform and worksheet. Hope this will convey better what I want to do.
    Attached Images Attached Images

  9. #9
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: How to loop through controls

    Thanks to all. Problem was solved by making some changes in naming conventions of userform controls and taking help from another thread of the same forum.

    Best Regards
    Imran Bhatti

+ 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. Need some help modifying my macro to loop different controls
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 55
    Last Post: 08-14-2016, 07:13 PM
  2. Can a loop within a loop refer to each others controls?
    By frontypro4x in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-19-2015, 07:59 PM
  3. Form Controls with for/next loop
    By beat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 07:15 AM
  4. Loop through controls in UserForm
    By JezLisle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2009, 05:38 AM
  5. [SOLVED] Order of controls in For Each Loop
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2005, 02:05 PM
  6. accesing controls in for each loop
    By Gixxer_J_97 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2005, 01:06 AM
  7. How to loop through controls on a MultiPage
    By 42N83W in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-14-2005, 08:06 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