Change Listview Font Color

ping0775

New Member
Joined
Jul 18, 2022
Messages
40
Office Version
  1. 2007
Platform
  1. Windows
Private Sub UserForm_Initialize()
Dim i As Long
Dim c As Integer
Me.ListView1.ListItems.Clear

Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 1), 30 'sl
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 2), 60 'inv no
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 3), 50 'date
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 5), 88 'billing
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 24), 38 'term
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 23), 50 'orig Amt
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 118), 50 'outstanding
Me.ListView1.ColumnHeaders.Add , , Sheet4.Cells(2, 119), 50 'Paid


Me.ListView1.ColumnHeaders(6).Alignment = lvwColumnRight
Me.ListView1.ColumnHeaders(7).Alignment = lvwColumnRight
Me.ListView1.ColumnHeaders(8).Alignment = lvwColumnRight


For i = 3 To Sheet4.Range("a1000000").End(xlUp).Row
If Sheet4.Cells(i, "DN").Value >= 0.01 Then



Set itm = Me.ListView1.ListItems.Add(Text:=Sheet4.Cells(i, "A")) 'sl
itm.ForeColor = vbRed

itm.SubItems(1) = Sheet4.Cells(i, "B") 'inv no
itm.SubItems(2) = Format(Sheet4.Cells(i, "C"), "dd-MM-yy") 'date
itm.SubItems(3) = Sheet4.Cells(i, "E") 'billing
itm.SubItems(4) = Sheet4.Cells(i, "X") 'term
itm.SubItems(5) = Format(Sheet4.Cells(i, "W"), "####0.00") 'orig Amt
itm.SubItems(6) = Format(Sheet4.Cells(i, "DN"), "####0.00") 'outstanding
itm.SubItems(7) = Format(Sheet4.Cells(i, "DO"), "####0.00") 'Paid

End If
Next i



End Sub

this code work, but only for the first column in the listview. " itm.ForeColor = vbRed"
the below subitems how to change the font to red color too?
anyone can assist?


i tried below code does work
Me.ListView1.ListItems.Add.SubItems(1).ForeColor = vbRed
itm.SubItems.ForeColor = vbRed
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Close Thread.
Fixed already with this code
Itm.ListSubItems(1).ForeColor = vbRed
Thanks Close Thread
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top