change listbox line colors

depcdivr

Active Member
Joined
Jan 21, 2008
Messages
350
Office Version
  1. 365
Platform
  1. Windows
Is there a way to use different line colors within a listbox.

I want to display a series of 27 different lines but I want some lines to be green, some yellow, some red, etc based on some criteria. Sort of like conditional formatting but for a listbox.


can this be done in a listbox or are we limited to only having one color in the listbox?

Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
There's no easy way with a listbox, but you could use a Spreadsheet control, you can colour that.
 
Upvote 0
I am not sure what you are thinking. Are you talking about just using a specific spreadsheet to display the data.

I am using a listbox because I am trying to display the data in a userform as opposed to a spreadsheet?
 
Upvote 0
NB:- Not sure it its there on the latest Excell, but,
If you look through the additional controls for your userform , you should find one similar to :- "Microsoft Office Spreadsheet 10".
If you place that on your Userform , By using the "Commands & Options" properties (Right click control) you can remove all the Scrollbars Header, even the Grid, so it looks like a "Listbox".
You can then colour the Text/Cells either by Using the "Property Options or by VB.
Like:_
Code:
Spreadsheet1.Range("A1:D10") = ActiveSheet.Range("A1:d10").value
Spreadsheet1.Range("A12:d12").Interior.ColorIndex = 6
 
Upvote 0
I was not aware of this option. I guess you learn something new every day.

Then I asusme that I populate the cells with something like
Code:
 spreadsheet1.cells(1,2)="hello"

When I first did this it comes up with an activeX warning. Then after that it does not. what was that warning about? How to I prevent it from coming up again?


Is there a way of removing the row/column labels(a,b,c etc)?
 
Upvote 0
When you have the Userform in Design Mode, if you right click on the Userform spreadsheet control , the Sub Menu that appears should have "Commands & Options" you can Modify the control how you like.
NB:- I find that sometimes the "Commands & Options" Does not show on the Sub Menu and you have to right click in various spots on the control to get it to appear. this may be just my version.
If you right click the Spreadsheet control and select view code, then go to the drop down at the top right of the code window, you will see all the Code "Events" that you can use.
I don't know why you got an error with that code , it works ok for me.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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