ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help taking values from List box to spreadsheet (https://www.excelbanter.com/excel-programming/375105-need-help-taking-values-list-box-spreadsheet.html)

trward79

Need help taking values from List box to spreadsheet
 
I am selecting values and putting them in a list box. I need to click a
button and have those vaues sent to a worksheet page, in A2 and down. I am
totally lost on this one. Please help...

Bob Phillips

Need help taking values from List box to spreadsheet
 
Worksheets("Sheet1").Range("A2").End(xlDown).Value = Listbox1.Value

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"trward79" wrote in message
...
I am selecting values and putting them in a list box. I need to click a
button and have those vaues sent to a worksheet page, in A2 and down. I am
totally lost on this one. Please help...




trward79

Need help taking values from List box to spreadsheet
 
I tried this, it does not take anything unless I select the value manualy.
Then it does that value only, and no others.

"Bob Phillips" wrote:

Worksheets("Sheet1").Range("A2").End(xlDown).Value = Listbox1.Value

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"trward79" wrote in message
...
I am selecting values and putting them in a list box. I need to click a
button and have those vaues sent to a worksheet page, in A2 and down. I am
totally lost on this one. Please help...





Tom Ogilvy

Need help taking values from List box to spreadsheet
 
Private Sub CommandButton1_Click()
Dim v as Variant
v = UserForm1.ListBox1.List
With Worksheets("Sheet4").Range("A2")
.Resize(UBound(v) - LBound(v) + 1, 1).Value = v
End With
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"trward79" wrote in message
...
I am selecting values and putting them in a list box. I need to click a
button and have those vaues sent to a worksheet page, in A2 and down. I am
totally lost on this one. Please help...




Dave Peterson

Need help taking values from List box to spreadsheet
 
Where is the listbox?

Is it on a userform?

Is it on a worksheet? If it's on a worksheet, is the listbox from the Forms
toolbar or from the control toolbox toolbar?

I'm gonna guess it's on a worksheet and from the control toolbox toolbar--with a
button from the control toolbox that does the work.

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long
Dim DestCell As Range

Set DestCell = Me.Range("a2")

With Me.ListBox1
DestCell.Resize(.ListCount).ClearContents
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With

End Sub

trward79 wrote:

I tried this, it does not take anything unless I select the value manualy.
Then it does that value only, and no others.

"Bob Phillips" wrote:

Worksheets("Sheet1").Range("A2").End(xlDown).Value = Listbox1.Value

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"trward79" wrote in message
...
I am selecting values and putting them in a list box. I need to click a
button and have those vaues sent to a worksheet page, in A2 and down. I am
totally lost on this one. Please help...





--

Dave Peterson


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com