Fordraiders
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the workbook example...
The code loads the contiguous range from A1 on the current sheet, if that's what you mean?
ASKER
OK Thanks
ASKER
Thanks
ASKER
Thanks
fordraiders