+ Reply to Thread
Results 1 to 2 of 2

For/ Next loop not working

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    222

    For/ Next loop not working

    I am trying to clear old entries in TextBoxes using this code
     With UserForm1
       For a = 1 To 6
       .TextBox & "a".Value=""
       Next a
       End With
    This fails with the & highlighted and a "Syntax error"
    Why is this wrong?
    John

  2. #2
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,175

    Re: For/ Next loop not working

    "a" is the letter a
    Try:

    Dim a As Integer
    With UserForm1
        For a = 1 To 6
            .Controls("TextBox" & a).Value = ""
        Next a
    End With

+ 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. [SOLVED] For loop is not working
    By Raj ASRP in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2020, 06:38 AM
  2. [SOLVED] Next loop is not working
    By Aatomo72 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2019, 01:57 PM
  3. [SOLVED] Loop not working!
    By Jstns in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2017, 07:57 AM
  4. For loop within loop not working correctly
    By HalPlz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2015, 12:06 AM
  5. Loop not working
    By blankus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2009, 04:16 AM
  6. Loop not working!!
    By Simon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2005, 12:05 PM
  7. Do...Loop not working
    By Sunny Lin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2005, 09: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