ListBox Color Validation

N323100

New Member
Joined
Mar 22, 2017
Messages
8
I have this userform with listbox, and I want something to have a color validation depending on what the user select in the Listbox, for Example if the user selected "Review" the font will change into rgbOrange etc.. depending on the list was selected. below is the standard code with out color validation.


Code:
Private Sub OptionButton1_Click()
Dim x       As Integer
Dim tVal    As String
Dim tLen    As Integer
Dim t1      As Integer
Dim t2      As Integer
If Me.TaskList.ListCount = 0 Then GoTo exitSub
For x = 0 To Me.TaskList.ListCount - 1
    If Me.TaskList.Selected(x) And viaForm = True Then
        With ActiveCell
            If Len(Trim(.Value)) > 0 Then .Value = .Value & Chr(10)
            .Value = .Value & Me.TaskList.List(x)
            t1 = InStr(1, ActiveCell.Value, Me.TaskList.List(x))
            .Characters(Start:=t1, Length:=Len(Me.TaskList.List(x))).Font.Color = vbBlack
        End With
    End If
    
Next x
For x = 0 To Me.TaskList.ListCount - 1
    Me.TaskList.Selected(x) = False
Next x
exitSub:
OptButtons_False
Me.OptionButton1.Value = False
Init_TaskList
chk_Selected
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I did not understand where you want the color validation applied. Is it on the list box, the worksheet or somewhere else?
Your current code deals only with the active cell.
Please explain.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top