ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2000 Visual Basic - Export Contents of ListBox into a worksh (https://www.excelbanter.com/excel-programming/315394-excel-2000-visual-basic-export-contents-listbox-into-worksh.html)

Ligaya

Excel 2000 Visual Basic - Export Contents of ListBox into a worksh
 
Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya

Alasdair Stirling[_2_]

Excel 2000 Visual Basic - Export Contents of ListBox into a worksh
 
I am not quite sure what you are trying to do, but this code will spit the
items in a listbox into a worksheet:

Private Sub CommandButton1_Click()
Dim i As Integer
For i = 0 To ListBoxX.ListCount - 1
With ActiveCell
.Value = ListBoxX.List(i)
.Offset(1, 0).Select
End With
Next i
End Sub

You will need to rename ListBoxX according to thae name that you are using.
You also need to identify the Workcheet and Cell address for the ActiveCell
refenence.

Hope this helps

Alasdair Stirling

"Ligaya" wrote:

Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya


Tom Ogilvy

Excel 2000 Visual Basic - Export Contents of ListBox into a worksh
 
Your question is pretty vague. Assume a multiselect listbox on a userform
or on a worksheet and a commandbutton triggers the action.

Private Sub Commandbutton1_Click()
Dim j as Long, i as long
j = 1
for i = 0 to me.listbox1.Listcount - 1
if me.listbox1.selected(i) then
Worksheets(1).cells(j,1).Value = me.listbox1.List(i)
j = j + 1
End if
Next
End Sub

perhaps the above will give you some ideas.
--
Regards,
Tom Ogilvy

"Ligaya" wrote in message
...
Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya




Ligaya

Excel 2000 Visual Basic - Export Contents of ListBox into a wo
 


"Alasdair Stirling" wrote:

I am not quite sure what you are trying to do, but this code will spit the
items in a listbox into a worksheet:

Private Sub CommandButton1_Click()
Dim i As Integer
For i = 0 To ListBoxX.ListCount - 1
With ActiveCell
.Value = ListBoxX.List(i)
.Offset(1, 0).Select
End With
Next i
End Sub

You will need to rename ListBoxX according to thae name that you are using.
You also need to identify the Workcheet and Cell address for the ActiveCell
refenence.

Hope this helps

Alasdair Stirling

"Ligaya" wrote:

Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya


You got what I want to do with the 2nd List Box.

Thanks.

Ligaya



Ligaya

Excel 2000 Visual Basic - Export Contents of ListBox into a wo
 


"Tom Ogilvy" wrote:

Your question is pretty vague. Assume a multiselect listbox on a userform
or on a worksheet and a commandbutton triggers the action.

Private Sub Commandbutton1_Click()
Dim j as Long, i as long
j = 1
for i = 0 to me.listbox1.Listcount - 1
if me.listbox1.selected(i) then
Worksheets(1).cells(j,1).Value = me.listbox1.List(i)
j = j + 1
End if
Next
End Sub

perhaps the above will give you some ideas.
--
Regards,
Tom Ogilvy

"Ligaya" wrote in message
...
Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya





Ligaya

Excel 2000 Visual Basic - Export Contents of ListBox into a wo
 


"Tom Ogilvy" wrote:

Your question is pretty vague. Assume a multiselect listbox on a userform
or on a worksheet and a commandbutton triggers the action.

Private Sub Commandbutton1_Click()
Dim j as Long, i as long
j = 1
for i = 0 to me.listbox1.Listcount - 1
if me.listbox1.selected(i) then
Worksheets(1).cells(j,1).Value = me.listbox1.List(i)
j = j + 1
End if
Next
End Sub

perhaps the above will give you some ideas.
--
Regards,
Tom Ogilvy

"Ligaya" wrote in message
...
Hi,

I developed 2 list boxes and succesfully added items to the first ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way to
place the items from ListBox to into another worksheet within the same
workbook.

Thanks.

Ligaya



Thanks. I was responding to an OptionButton (same finction in my program
as CommandButton).

Ligaya

Tom Ogilvy

Excel 2000 Visual Basic - Export Contents of ListBox into a wo
 
Well, if you want everything in listbox2 listed in column A, starting in row
1

Private Sub OptionButton1_click()
Dim lbx as MSForms.Listbox
set lbx = me.Listbox2
if me.optionButton1.Value then
with worksheets(1)
.Range("A1").Resize(lbx.listcount,1).Value = _
lbx.List
end with
End if
End sub

--
Regards,
Tom Ogilvy


"Ligaya" wrote in message
...


"Tom Ogilvy" wrote:

Your question is pretty vague. Assume a multiselect listbox on a

userform
or on a worksheet and a commandbutton triggers the action.

Private Sub Commandbutton1_Click()
Dim j as Long, i as long
j = 1
for i = 0 to me.listbox1.Listcount - 1
if me.listbox1.selected(i) then
Worksheets(1).cells(j,1).Value = me.listbox1.List(i)
j = j + 1
End if
Next
End Sub

perhaps the above will give you some ideas.
--
Regards,
Tom Ogilvy

"Ligaya" wrote in message
...
Hi,

I developed 2 list boxes and succesfully added items to the first

ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way

to
place the items from ListBox to into another worksheet within the

same
workbook.

Thanks.

Ligaya



Thanks. I was responding to an OptionButton (same finction in my program
as CommandButton).

Ligaya




Ligaya

Excel 2000 Visual Basic - Export Contents of ListBox into a wo
 


"Tom Ogilvy" wrote:

Well, if you want everything in listbox2 listed in column A, starting in row
1

Private Sub OptionButton1_click()
Dim lbx as MSForms.Listbox
set lbx = me.Listbox2
if me.optionButton1.Value then
with worksheets(1)
.Range("A1").Resize(lbx.listcount,1).Value = _
lbx.List
end with
End if
End sub

--
Regards,
Tom Ogilvy


"Ligaya" wrote in message
...


"Tom Ogilvy" wrote:

Your question is pretty vague. Assume a multiselect listbox on a

userform
or on a worksheet and a commandbutton triggers the action.

Private Sub Commandbutton1_Click()
Dim j as Long, i as long
j = 1
for i = 0 to me.listbox1.Listcount - 1
if me.listbox1.selected(i) then
Worksheets(1).cells(j,1).Value = me.listbox1.List(i)
j = j + 1
End if
Next
End Sub

perhaps the above will give you some ideas.
--
Regards,
Tom Ogilvy

"Ligaya" wrote in message
...
Hi,

I developed 2 list boxes and succesfully added items to the first

ListBox.
I then selected items from ListBox1 to ListBox2. What is the best way

to
place the items from ListBox to into another worksheet within the

same
workbook.

Thanks.

Ligaya


Thanks. I was responding to an OptionButton (same finction in my program
as CommandButton).

Ligaya



Thanks. It worked like a charm. I was dumping the contents of the ListBox
into a range in the worksheet.

Ligaya


All times are GMT +1. The time now is 09:43 AM.

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