change the font color in listbox user form if theres a value in counter 9

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Hi i have userform with the listbox and is it possible to change the color of the value if found in listbox below it is the code of the list values.

i want
VBA Code:
Next
                    .AddItem
                    .List(counter, 0) = sourceCell.Offset(0, 0).Value
                     .List(counter, 1) = Application.Text(sourceCell.Offset(0, 1).Value, "hh:mm")
                    .List(counter, 2) = sourceCell.Offset(0, 2).Value
                    .List(counter, 3) = sourceCell.Offset(0, 3).Value
                    .List(counter, 4) = sourceCell.Offset(0, 4).Value
                    .List(counter, 5) = sourceCell.Offset(0, 5).Value
                    .List(counter, 6) = sourceCell.Offset(0, 6).Value
                    .List(counter, 7) = sourceCell.Offset(0, 7).Value
                    .List(counter, 8) = sourceCell.Offset(0, 8).Value
                    .List(counter, 9) = sourceCell.Offset(0, 9).Value   [COLOR=rgb(184, 49, 47)] 'color to be change if value is contain to Red or Blue[/COLOR]
               
                End With
               
                counter = counter + 1
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
If you want to change the font colour for just one line, then I'm afraid your out of luck.
 
Upvote 0
Not that I'm aware of, it's all or nothing.
 
Upvote 0
Thank you for quick reply, how do you change the color of all list box content?
 
Upvote 0
You can either change the forecolor in the properties window, or you can use something like
VBA Code:
   Me.ListBox1.ForeColor = vbRed
 
Upvote 0
Solution
Hi many thanks for the above better than nothing and also thank you for your promote respond. :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,750
Messages
6,180,736
Members
452,995
Latest member
isldboy

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