MULTISELECT listview items...
I have a listview filled with value.
Is possible to select one or more line in listy view and store the value of first item in a sheet.
Example:
in listview
column1 column2 column3
10000 aaaaaaaa bbbbbbbb
15000 zzzzzzzzz cccccccc
...
20000 hhhhhhhh adababab
i select line 1 and line 2
the lines seected assuming autoamticlly the black color
insert in sheet:
column a column b column c
10000 aaaaaaaa bbbbbbbb
15000 zzzzzzzzz cccccccc
naturally if i reclick on line 1 and 2 in listview delete the refered line in sheet and recolr the line in listview with the color of deault...
Sorry for bad english but i hope understand me:-)
Re: MULTISELECT listview items...
Not sure if I understand you but
Select 2 rows in a listview.
Copy to Excel
Paste
Where is this listview at?
Re: MULTISELECT listview items...
I am assuming that you are using Excel 2003...
Here is a sample code to export data from listview to excel sheet....
vb Code:
'~~> Generating Sample Data.
Private Sub UserForm_Activate()
'~~> Ensure that the listview's multiselect property is set to true
Dim clmAdd As ColumnHeader, itmAdd As ListItem, j As Integer
'~~> Adding 3 Column Headers to the ListView control
Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header1")
Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header2")
Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header3")
'~~> Set the view property of the Listview control to Report view
ListView1.View = lvwReport
'~~> Adding Sample data to the ListView control
For j = 1 To 5
Set itmAdd = ListView1.ListItems.Add(Text:="Sample " & j)
itmAdd.SubItems(1) = "SampleSubItemOne" & j
itmAdd.SubItems(2) = "SampleSubItemTwo" & j
Next j
End Sub
'~~> Export Data to Sheet from listview
Private Sub CommandButton1_Click()
Dim i As Integer, R As Integer
'~~> Get the First Empty Row
R = Sheets("Sheet1").Range("A65536").End(xlUp).Row + 1
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Selected = True Then
'~~> Data copied to Column A, B and C
Sheets("Sheet1").Range("A" & R).Value = ListView1.ListItems(i).Text
Sheets("Sheet1").Range("B" & R).Value = ListView1.ListItems(i).SubItems(1)
Sheets("Sheet1").Range("C" & R).Value = ListView1.ListItems(i).SubItems(2)
R = R + 1
End If
Next i
End Sub
I am sure you can take care of
Quote:
naturally if i reclick on line 1 and 2 in listview delete the refered line in sheet and recolr the line in listview with the color of deault...
If you get stuck, simply post the code that you have tried and we will definitely help you out ;)