ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   list box question (https://www.excelbanter.com/excel-programming/343622-list-box-question.html)

Chris Salcedo

list box question
 
I now have a populated list box on my form. I now need to take each
value (its the name of a named range) and copy that range to another
sheet...


How do I create the loop ??????

On Error Resume Next
Sheets(Me.DestTextBox.Text).Delete

Sheets.Add
ActiveSheet.Name = Me.DestTextBox.Text 'my sheet

The "somehow read the RightListBox starting with the first entry"
Loop

Set lastcell = Cells.SpecialCells(xlLastCell)' find the last
mrows = lastcell.Row ' used row

Set rng = the first item in the list

rng.Copy Destination:=Worksheets(Me.DestTextBox.Text).Range ("A" &
(mrows + 1))

Next entry

Any ideas ??????

Thanks

Chris


Harald Staff

list box question
 
Hi

Using an ActiveX listbox:

Sub test()
Dim L As Long
Dim S As String
For L = 0 To Me.ListBox1.ListCount - 1
S = Me.ListBox1.List(L)
MsgBox S
Next
End Sub

HTH. Best wishes Harald

"Chris Salcedo" skrev i melding
ups.com...
I now have a populated list box on my form. I now need to take each
value (its the name of a named range) and copy that range to another
sheet...


How do I create the loop ??????

On Error Resume Next
Sheets(Me.DestTextBox.Text).Delete

Sheets.Add
ActiveSheet.Name = Me.DestTextBox.Text 'my sheet

The "somehow read the RightListBox starting with the first entry"
Loop

Set lastcell = Cells.SpecialCells(xlLastCell)' find the last
mrows = lastcell.Row ' used row

Set rng = the first item in the list

rng.Copy Destination:=Worksheets(Me.DestTextBox.Text).Range ("A" &
(mrows + 1))

Next entry

Any ideas ??????

Thanks

Chris





All times are GMT +1. The time now is 11:55 PM.

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