AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Is there something missing/wrong ?
Code:
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)

    If ColumnHeader.text = "Title" Then
        Me.ListView1.Sorted = True
        Me.ListView1.SortKey = 0
        If Me.ListView1.SortOrder = lvwDescending Then
                Me.ListView1.SortOrder = lvwAscending
            Else
                Me.ListView1.SortOrder = lvwDescending
            End If
        Else
            Me.ListView1.Sorted = False
    End If
End Sub
 

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.
I have been wanting to learn about Listview
Would you please show me all the code in your Userform.
I would like to see how you load values into Listview and handle other task.
And I may be able to help you also with your question
 
Last edited:
Upvote 0
LOL I normally ask the questions! Have a read here...
https://10tec.com/articles/excel-vba-listview-control-examples.aspx

Don't mean to wimp out but I'm sure that'll explain it better than I can.
Would try and help more, but I'm feeling my way here too ! You'll probably need the OCX.. when I added it I was sure
an extra control was added to the toolbox, and I dragged that onto the Form. But I don't see it there now. Puzzling.
 
Upvote 0
Hope you had some success. It's an nice control !
I figured out my problem..
Me.ListView1.SortKey = 0

The zero refers to the column number to sort by. 0= first, 1= next etc.
If you set .Checkboxes = True the first column acquires a checkbox and this

Code:
.ListView1.ListItems(RowNumber).Checked = 'True or False

If you're looping through adding data .ListView1.ListItems.Count will give you the current row Number.
I know you can rearrange columns so the checkbox isn't first, but I lost the instructions and can't find them again. (It was a Google search)
 
Upvote 0
I never looked into it. I wanted to see all the code you were using just to get a ideal but you did not want to show me all your code so that's OK I will figure things out some day

At lot of people on this forum want us to write code for them and I do that. I just wanted to do the opposite here and have you show me your code.
 
Upvote 0
Well it may be my code ain't worth showing !
This is the first time I've had a Listview control in and working, so it's bound to be less than robust. I'm tweaking and finding things out as I go.
 
Upvote 0
I have now learned how to load values into a Listview and sort them next step is what else can I do with Listview.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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