PDA

View Full Version : Conditional Formatting in Listview



Cyril Beki
08-26-2021, 03:05 PM
Dear friends,

Is it possible to format rows in listview according to status: I need a conditional formatting like this:
1- When Column 13 value is "Down" ,I want the whole row in my listview becomes red.
2- When Column 13 value is "Up" ,I want the whole row in my listview becomes green.

Another thing i would like to do is to change the time and date format inside listview
1. Date change to - dd/mm/yy
2. Time change to - hh:mm

i've search tons of example but could't find one, i hope someone can help me with this.
Attached herewith is the excel file


Waiting for your reply.Thanks in advance,

Paul_Hossler
08-26-2021, 06:31 PM
Look at

http://www.vbaexpress.com/kb/getarticle.php?kb_id=916

to get some ideas

Not exactly what you were asking, but seems close

arnelgp
08-28-2021, 03:40 AM
check your worksheet's Conditional Format.
You already have that in your CF.
You can change the date format by using Custom date format.
select the cells you want to change the format, right-click
then select Format Cells..

p45cal
08-28-2021, 11:58 AM
It isn't straightforward to change the background of the 'cells' in a ListView control, but it is easy to change the font colour (ForeColor).
You code had 2 ways of populating the ListView, and one was immediately overwriting what the other had done, so I removed some code from the Extract macro.
See attached.

I see this has been cross posted at https://www.excelforum.com/excel-programming-vba-macros/1357819-change-rowcolor-in-listview-depending-on-value-excel-vba.html
Please read http://www.excelguru.ca/content.php?184
It's not very nice to discover that after having spent hours solving your problem that you've already had a solution elsewhere.
Most forums like this one insist on you supplying links to all your cross posts.