inactiveUser214710
Board Regular
- Joined
- Apr 27, 2012
- Messages
- 171
hi everyone
I try through net to know how to transfer data from listbox, in userform, to worksheet, but unfortunately without result.
I have, as a sample, a combobox (cbo1) that chooses the information to be shown in the listbox (lstPed), and with a commandbox (cmdPrin), which I pretend save in to worksheet, (Sheet6). In this sheet has headers that occupy three columns and two rows (A1:C2).
I woud like it to be possible with (Cmdprin), transfer the respective data for that sheet in A3:C20 cells in Sheet3. How can I do That?
Thank you
The code that I tried was the bellow:
It works BUT this code works with its immediate filling, but it continues to think or continues to go through the spreadsheet, for some time (+ - one minute), without let to passe to next operation.
Will be there a simpler way to do this? thank you for your help
Jdcar
I try through net to know how to transfer data from listbox, in userform, to worksheet, but unfortunately without result.
I have, as a sample, a combobox (cbo1) that chooses the information to be shown in the listbox (lstPed), and with a commandbox (cmdPrin), which I pretend save in to worksheet, (Sheet6). In this sheet has headers that occupy three columns and two rows (A1:C2).
I woud like it to be possible with (Cmdprin), transfer the respective data for that sheet in A3:C20 cells in Sheet3. How can I do That?
Thank you
The code that I tried was the bellow:
It works BUT this code works with its immediate filling, but it continues to think or continues to go through the spreadsheet, for some time (+ - one minute), without let to passe to next operation.
Will be there a simpler way to do this? thank you for your help
Jdcar
VBA Code:
Private Sub cmdPrin_Click()
Sheets("sheet6").Select
If lstPed.ListCount = 0 Then
MsgBox ("Não há Itens a serem impressos..."), vbInformation, ("erro")
Else
If Range("A3").Select = "" Then
' do anything
Else
'clean
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A3").Select
End If
‘ roll the data into the spreadsheet
Dim Item As Double
Dim linha As Integer
linha = 3
For Item = 0 To lstPed.ListCount - 1
Sheets("sheet6").Cells(linha, 1) = lstPed.List(Item, 0)
Sheets("sheet6").Cells(linha, 2) = lstPed.List(Item, 1)
Sheets("sheet6").Cells(linha, 3) = lstPed.List(Item, 2)
linha = linha + 1
Next
End If
End sub