+ Reply to Thread
Results 1 to 2 of 2

BackGround Color applied to all userforms

Hybrid View

  1. #1
    Registered User
    Join Date
    08-04-2017
    Location
    CONSTANTA
    MS-Off Ver
    2010
    Posts
    10

    BackGround Color applied to all userforms

    Hello,

    I am fairly new in vba programming and i`m trying to apply a custom color to all of my userforms. The code bellow modifies the color of a single userform based on the rgb values inserted in 3 cells. Can i apply the change to more than one userform? I have found a code that does that and much more (Beyond Excel: Adding Color and Glow Effects to Excel's UserForms on youtube, i am not allowed to post the youtube link yet) but after two days in which i tried to understand the code i realized that it is much too complex for my current vba level.

    Option Explicit
    Sub UserForm3x()
    
        Call updateRGB
        UserForm3.Show
    
    End Sub
    Sub updateRGB()
    Dim r As Integer, g As Integer, b As Integer, x As Integer, y As Integer, z As Integer
    
    r = Sheets("TEST").Range("A1").Value
    g = Sheets("TEST").Range("B1").Value
    b = Sheets("TEST").Range("C1").Value
    UserForm3.BackColor = RGB(r, g, b)
    UserForm3.TextBox2 = r
    UserForm3.TextBox3 = g
    UserForm3.TextBox4 = b
    
    End Sub
    Thanks,
    Have a nice day
    Chris

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: BackGround Color applied to all userforms

    Have a look at attached, if you are working through a series of Userforms might be useful starting point
    Option Explicit
    Sub UserForm3x()
        Call updateRGB
    End Sub
    Sub updateRGB()
    Dim r As Integer, g As Integer, b As Integer, x As Integer, i As Integer
    Dim strFormName As String
    For i = 1 To 3
    strFormName = "UserForm" & i
    With Form(strFormName)
    r = Sheets("TEST").Range("A1").Value
    g = Sheets("TEST").Range("B1").Value
    b = Sheets("TEST").Range("C1").Value
        .BackColor = RGB(r, g, b)
        .Label1.BackColor = RGB(r - 20, g - 20, b - 20)
        .TextBox1.BackColor = RGB(r + 30, g + 30, b + 30)
        .ListBox1.BackColor = RGB(r - 80, g - 80, b - 80)
        .ComboBox1.BackColor = RGB(r - 50, g - 50, b - 50)
        MsgBox "Show Userform" & i
        .Show vbModal
    End With
    
    Next i
    End Sub
    Function Form(Name As String) As Object
      Set Form = CallByName(UserForms, "Add", VbMethod, Name)
    End Function
    Attached Files Attached Files

+ 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. Replies: 8
    Last Post: 04-02-2016, 04:00 AM
  2. Change cell background color based on another cells background color
    By Queo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 06-10-2014, 05:28 AM
  3. Replies: 4
    Last Post: 12-29-2013, 11:41 PM
  4. [SOLVED] Cell background colour applied to other cells
    By Strazdas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2013, 06:33 AM
  5. Replies: 6
    Last Post: 11-07-2012, 10:46 AM
  6. [SOLVED] Macro to change all cells with a certain background color in another background color
    By kevinvzandvoort in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2012, 11:04 AM
  7. [SOLVED] Applied color to excel cell but no color appears
    By chris_bartnick in forum Excel General
    Replies: 1
    Last Post: 12-05-2005, 11:10 AM

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