Link to home
Start Free TrialLog in
Avatar of Tocogroup
TocogroupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Is it possible to highlight Excel VBA Listbox items in red according to certain criteria ?

Hi,

I have an Excel application with an Orders userform containing a listbox. I'd like to highlight the text of those Listbox items which haven't yet been invoiced (I use a status text box to determine this).

Any ideas ?

thanks
Toco
Avatar of Gregory Miller
Gregory Miller
Flag of United States of America image

ListBox1.Clear
Dim c As Long
c = 1
For Each cll In Range("Table1").Columns(1).SpecialCells(xlCellTypeVisible).Cells
    ListBox1.AddItem cll.Value
    If Cells(cll, 5).Value <> "" Then
        ListBox1.items(c).ForeColor = vbRed
    End If
    c = c + 1
Next cll
Avatar of Tocogroup

ASKER

Thanks for your help.

I load my listbox from an array in one single statement for speed and efficiency.....

   liSales.List = SalesArray()

Is it possible to act on the listbox items directly, in some way or another? For example......

      If  liSales.Items(rowno,colno).Value <> "Invoiced"  Then
           liSales.Items(row).ForeColor = vbRed
      End If

I tried the above but I couldn't get it to work
ASKER CERTIFIED SOLUTION
Avatar of Tocogroup
Tocogroup
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No further response from members.
I found out elsewhere that Listbox controls cannot be formatted in the way I wish. However ListView controls (an Add-in) are  formattable.