Banner

Sunday, May 21, 2017

Label Width And Backcolor And Caption Change By Textbox Userform Excell VBA



Private Sub TextBox1_Change()
a = Len(Me.TextBox1.Text)
If a <= 12 Then
Me.Label1.Width = a * 19
If a <= 4 Then
Me.Label1.BackColor = vbRed
Me.Label1.Caption = "Weak"
ElseIf a <= 8 Then
Me.Label1.BackColor = vbYellow
Me.Label1.Caption = "Good"
Else
Me.Label1.Caption = "Excellent"
Me.Label1.BackColor = vbGreen
End If
End If
End Sub

Tuesday, May 2, 2017

Multiple Combobox Additem Multiple Criteria Userform Excell VBA



Private Sub UserForm_Initialize()
Dim i As Long
For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
For a = 1 To 3
If Sheet1.Cells(1, a).Value = Me("Label" & a).Caption Then
Me("Combobox" & a).AddItem Sheet1.Cells(i, a).Value
End If
Next a
Next i
End Sub