Solved

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

Posted on 2013-11-16
4
721 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
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.

697 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