[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2501
  • Last Modified:

Converting to Listview from Listbox vba excel

exce 2003 vba...

I have the following userform loading a "listbox" from a sheet range...

I want to convert to ListView...to make the sorting easier

I used\
ListView1.RowSource = "List!" & usedRng.Address

But I just got a blank grid ?

Thanks
fordraiders


Public Sub LoadData()
On Error Resume Next
      Dim usedRng As Range
      Sheets("List").Activate
      
      
    Cells.Select
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
      
      
      
      
      
      ' get the rnge from the spreadsheet
         DetermineUsedRange usedRng
           ' select the range for the listbox
            ListBox1.RowSource = "List!" & usedRng.Address
           
End Sub
Sub DetermineUsedRange(ByRef theRng As Range)
Dim FirstRow As Integer, FirstCol As Integer, _
   LastRow As Integer, LastCol As Integer
On Error GoTo handleError
FirstRow = Cells.Find(What:="*", _
     SearchDirection:=xlNext, _
     SearchOrder:=xlByRows).Row
FirstCol = 1
'FirstCol = Cells.Find(What:="1", _
'     SearchDirection:=xlNext, _
'     SearchOrder:=xlByColumns).Column

LastRow = Cells.Find(What:="*", _
     SearchDirection:=xlPrevious, _
     SearchOrder:=xlByRows).Row
LastCol = Cells.Find(What:="*", _
     SearchDirection:=xlPrevious, _
     SearchOrder:=xlByColumns).Column
Set theRng = Range(Cells(FirstRow, FirstCol), _
   Cells(LastRow, LastCol))
handleError:
End Sub

Open in new window

0
Fordraiders
Asked:
Fordraiders
  • 4
  • 2
1 Solution
 
Rory ArchibaldCommented:
There is no RowSource property. Here's a sample showing how to load it from a range and how to implement column sorting (just click on a column header)

ListView-sample.xls
0
 
FordraidersAuthor Commented:
rorya, Thanks, So I was debugging.. The column Number and Row count will be determined always by the code correct...?

Thanks
fordraiders
0
 
FordraidersAuthor Commented:
Thanks for the workbook example...
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
Rory ArchibaldCommented:
The code loads the contiguous range from A1 on the current sheet, if that's what you mean?
0
 
FordraidersAuthor Commented:
OK Thanks
0
 
FordraidersAuthor Commented:
Thanks
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now