+ Reply to Thread
Results 1 to 9 of 9

Loop Clear Text Boxes

  1. #1
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Loop Clear Text Boxes

    Can anyone help with this code, it doesn't work. It should loop through all the text boxes and clears them. The syntax is probably wrong.

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Loop Clear Text Boxes

    I don't mean to insult you, but what is here is so wrong that I can't tell how to correct it.

    Please give the following information:

    What are these textboxes on--a worksheet, or a UserForm?
    Are these ActiveX or Forms textboxes?
    Are there six the textboxes you want to clear (plus one combobox)? I can't sort out why are you iterating 4 times.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Re: Loop Clear Text Boxes

    They are mixture of textboxes and combo boxes on a userform.

    They are named:

    cmb_PackF_Level1
    cmb_PackF_Level2
    cmb_PackF_Level3
    cmb_PackF_Level4

    txtPackFQty1
    txtPackFQty2
    txtPackFQty3
    txtPackFQty4

    etc

    I just wanted to tidy up my code, instead of having to repeat that same block of code 4 times.

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

    Re: Loop Clear Text Boxes

    Why not just
    Please Login or Register  to view this content.
    and then
    Please Login or Register  to view this content.
    This will clear all, unless there are some you don't want cleared?
    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!!!

  5. #5
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Re: Loop Clear Text Boxes

    there are some I don't want cleared

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

    Re: Loop Clear Text Boxes

    If you want to loop through textboxes to clear them then use this code. This will loop through Textbox1 to TextBox4 and clear them.
    Please Login or Register  to view this content.
    Last edited by sintek; 04-05-2017 at 10:23 AM.

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

    Re: Loop Clear Text Boxes

    Quote Originally Posted by Johnny0811 View Post
    They are mixture of textboxes and combo boxes on a userform.

    They are named:

    cmb_PackF_Level1
    cmb_PackF_Level2
    cmb_PackF_Level3
    cmb_PackF_Level4

    txtPackFQty1
    txtPackFQty2
    txtPackFQty3
    txtPackFQty4

    etc

    I just wanted to tidy up my code, instead of having to repeat that same block of code 4 times.
    So I guess this would work for the first instance....i.e cmb_PackF_Level
    Please Login or Register  to view this content.

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

    Re: Loop Clear Text Boxes

    And so on until you put all 4 names in

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Re: Loop Clear Text Boxes

    thank you.

+ 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 to create a for loop that refers to a number of text boxes
    By forrestgump1980 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2015, 10:52 AM
  2. Loop through userform text boxes
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2014, 10:41 AM
  3. [SOLVED] Clear all text boxes-combo boxes in a userform.
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2014, 11:16 AM
  4. [SOLVED] clear userform does not clear all boxes
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-23-2013, 11:43 AM
  5. Replies: 2
    Last Post: 02-19-2010, 03:55 PM
  6. Change Text Boxes in Do While Loop
    By wfire in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-04-2009, 03:18 PM
  7. [SOLVED] Forms - Loop thru text boxes
    By Michael Beckinsale in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-10-2006, 02:00 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