Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

show the colored value of specific column in lastview

0

hi, everybody 

i have sheet1 contains data  and contains column d  colored value  i would show  colored value in listview

Answer
Discuss

Answers

0

here is a snippet of code to get you started.

there will need to be a bit more logic added to set up the colours you want 

'Count number of columns in source range
colCount = rngData.Columns.Count

'Now we fill our ListView
For i = 2 To rowCount
Set listItem = Me.ListView1.ListItems.Add(Text:=rngData(i, 1).Value)
For j = 2 To colCount
listItem.ListSubItems.Add Text:=rngData(i, j).Value
If j = 4 Then
    listItem.ListSubItems.Item(3).ForeColor = vbRed
End If

I have added the xl with the code in it. 

From the macro editor select the form then right mouse click on it to show the code

Discuss

Discussion

thanks for your replaying   but, i don't know where exactly put tis code which event 
 i try putting this code  in these events  it doesn't work
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)   Private Sub UserForm_Initialize()

leopard (rep: 88) Aug 12, '19 at 6:55 am
I have just updated the file with additional code to give you a bit of flexibility in the colours using  case statements
k1w1sm (rep: 197) Aug 14, '19 at 6:32 pm
Did that code help?
k1w1sm (rep: 197) Sep 18, '19 at 10:20 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login