Solved

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

Posted on 2013-11-16
4
514 Views
Last Modified: 2013-12-09
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
0
Comment
Question by:Tocogroup
  • 3
4 Comments
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39653797
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
0
 

Author Comment

by:Tocogroup
ID: 39654210
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
0
 

Accepted Solution

by:
Tocogroup earned 0 total points
ID: 39654227
I tried your code too and couldn't get that to work either. Did you test your code ?
0
 

Author Closing Comment

by:Tocogroup
ID: 39705745
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.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now