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
Bookmarks