white_flag
04-21-2010, 04:06 AM
hello
what is the most easy way to populate multiple columns in Listview from some ranges?
listviewcol. 1 listviewcol. 2 listviewcol. 3
range 1 range 2 range 3
and this is my code:
Private Sub UserForm_Initialize()
Dim i As Long
Dim LR As Long, LC As Long
Dim cell As Range
With Sheets("Sheet1")
LR = .Range("A" & .Rows.Count).End(xlUp).Row
LC = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
With ListView1
For Each cell In Range("A1", Cells(1, LC))
.ListItems.Add , , cell
ListView1_ItemClick .ListItems(.SelectedItem.Index) 'fill edit controls
Next cell
For Each cell In Range("A2", Cells(2, LC))
.ListSubItems.Add , , cell << error
ListView1_ItemClick .ListItems(.SelectedItem.Index) 'fill edit controls
Next cell
.ColumnHeaders.Add , , "Name", Me.TextBox1.Width 'Add columns
.ColumnHeaders.Add , , "Density", Me.TextBox2.Width
.HideColumnHeaders = False 'set some properties
.View = lvwReport
.Gridlines = True
End With
End Sub
thanx for the advice
what is the most easy way to populate multiple columns in Listview from some ranges?
listviewcol. 1 listviewcol. 2 listviewcol. 3
range 1 range 2 range 3
and this is my code:
Private Sub UserForm_Initialize()
Dim i As Long
Dim LR As Long, LC As Long
Dim cell As Range
With Sheets("Sheet1")
LR = .Range("A" & .Rows.Count).End(xlUp).Row
LC = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
With ListView1
For Each cell In Range("A1", Cells(1, LC))
.ListItems.Add , , cell
ListView1_ItemClick .ListItems(.SelectedItem.Index) 'fill edit controls
Next cell
For Each cell In Range("A2", Cells(2, LC))
.ListSubItems.Add , , cell << error
ListView1_ItemClick .ListItems(.SelectedItem.Index) 'fill edit controls
Next cell
.ColumnHeaders.Add , , "Name", Me.TextBox1.Width 'Add columns
.ColumnHeaders.Add , , "Density", Me.TextBox2.Width
.HideColumnHeaders = False 'set some properties
.View = lvwReport
.Gridlines = True
End With
End Sub
thanx for the advice