+ Reply to Thread
Results 1 to 4 of 4

Conditional formatting userform textbox based on textbox value

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    Solihull, West Midlands
    MS-Off Ver
    2010
    Posts
    19

    Conditional formatting userform textbox based on textbox value

    Hi All,

    I've been using the following code to conditionally format userform textboxes based on a specific value (in this case 2490):

    Sub SetTextBoxA10(ByVal aBox As Integer)
    
    With UserForm10.Controls("TextBox" & aBox)
        If .Text <> "-" Then
        If .Text <> "" Then
            If .Text >= 2490 Then .BackColor = RGB(0, 255, 0)
            If .Text >= 2490 Then .ForeColor = RGB(0, 0, 0)
            If .Text < 2490 Then .BackColor = RGB(255, 0, 0)
            If .Text < 2490 Then .ForeColor = RGB(0, 0, 0)
        End If
       End If
     If .Text = "-" Or .Text = "" Then .BackColor = RGB(128, 128, 128)
     If .Text = "-" Or .Text = "" Then .ForeColor = RGB(0, 0, 0)
    End With
    
    
    End Sub
    What I'm looking to do now is amend this so rather than use a specific value, to use the value in a specific textbox on the same userform.

    Can anyone help with this?

    Thanks


  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Conditional formatting userform textbox based on textbox value

    abox.value
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    04-04-2013
    Location
    Solihull, West Midlands
    MS-Off Ver
    2010
    Posts
    19

    Re: Conditional formatting userform textbox based on textbox value

    Quote Originally Posted by nathansav View Post
    abox.value
    Yeah thanks just figured it out

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Conditional formatting userform textbox based on textbox value

    No worries, how's sunny solihull, do you work at Npower?

+ 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] Conditional Formatting based on TextBox criteria.
    By pipoliveira in forum Excel General
    Replies: 2
    Last Post: 04-11-2014, 09:01 AM
  2. Replies: 4
    Last Post: 01-29-2014, 05:53 AM
  3. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  4. Userform: Pass textbox values to another textbox on button press
    By adjustermn in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2010, 11:19 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