?
Solved

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

Posted on 2013-11-16
4
Medium Priority
?
1,013 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 11

Expert Comment

by:Gregory Miller
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

752 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