+ Reply to Thread
Results 1 to 2 of 2

Changing multiple textboxes format on a userform

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    111

    Changing multiple textboxes format on a userform

    Good day,

    I hope this e-mail finds you well.
    I was wondering if someone can show me a shorter way of applying a simple conditional formatting code to multiple textboxes on my userform.

    I have the following code, but want to apply it to a number of textboxes.

    Lets say for example, the same code I want to apply to TextBox 1 to 10.

    Private Sub Textbox31_Change()
    
    
       With TextBox31
           Select Case .Value
           
           Case Is = "No", "no"
              .BackColor = vbRed
           Case Is = "Yes", "yes"
              .BackColor = vbGreen
           Case Is = ""
              .BackColor = vbWhite
    
           End Select
       End With
    
    End Sub
    Thank you in advance!

  2. #2
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: Changing multiple textboxes format on a userform

    I believe you can use this below... try it and see

    Dim Numtboxes as Long
    Numtboxes = HOWEVER MANY TEXTBOXES YOU NEED TO EDIT... 30
    For i = 1 to Numtboxes
       With TextBox&i
           Select Case .Value
           
           Case Is = "No", "no"
              .BackColor = vbRed
           Case Is = "Yes", "yes"
              .BackColor = vbGreen
           Case Is = ""
              .BackColor = vbWhite
    
           End Select
       End With
    Next i

+ 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] Curency format in textboxes of userform
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-11-2014, 12:36 PM
  2. Tabbing throug userform's Textboxes, Changing defauld behaviour
    By vin1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2012, 08:38 AM
  3. Formatting Multiple Userform Textboxes
    By badeye in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2010, 09:14 AM
  4. Is there a way to format all TextBoxes on a UserForm the same at one time?
    By D3Pratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2009, 09:09 AM
  5. Changing all textboxes on a userform
    By Mat K in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2005, 06:54 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