ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Worksheets to a Workbook using a MultiSelect List Box (https://www.excelbanter.com/excel-programming/450088-adding-worksheets-workbook-using-multiselect-list-box.html)

wkwells

Adding Worksheets to a Workbook using a MultiSelect List Box
 
I have a workbook that I want to be able to add worksheets to it by checking selections in a MultiSelect Listbox, and I want the Tab Name to be the same as the Name selected in the MultiSelect Listbox.

I am stumped, I figured how to print sheets from a MultiSelect Box and even delete worksheets, but adding them has my puzzled.

Thank you in advance for any help.

WKWells

--
Posted by Mimo Usenet Browser v0.2.5
http://www.mimousenet.com/mimo/post



isabelle

Adding Worksheets to a Workbook using a MultiSelect List Box
 
hi,

i suppose that the ListBox have a single column
otherwise
for example, to retrieve the value of the 3rd column of a Listbox
ListBox1.List(i, 2)

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
On Error Resume Next
Sheets(ListBox1.List(i)).Select
If Err.Number < 0 Then
Err.Clear
Sheets.Add(After:=Sheets(Sheets.Count)).Name = ListBox1.List(i)
Else
MsgBox " This sheet <" & ListBox1.List(i) & " already exist"
End If
End If
Next i

isabelle

Le 2014-05-21 12:35, wkwells a écrit :
I have a workbook that I want to be able to add worksheets to it by checking selections in a MultiSelect Listbox,
and I want the Tab Name to be the same as the Name selected in the MultiSelect Listbox.
I am stumped, I figured how to print sheets from a MultiSelect Box and even delete worksheets, but adding them has my puzzled.

Thank you in advance for any help.

WKWells


wkwells

Adding Worksheets to a Workbook using a MultiSelect List Box
 
Perfect thank you much

On 23 May 2014 11:21 PM ,isabelle wrote:
hi,

i suppose that the ListBox have a single column
otherwise
for example, to retrieve the value of the 3rd column of a Listbox
ListBox1.List(i, 2)

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
On Error Resume Next
Sheets(ListBox1.List(i)).Select
If Err.Number < 0 Then
Err.Clear
Sheets.Add(After:=Sheets(Sheets.Count)).Name = ListBox1.List(i)
Else
MsgBox " This sheet <" & ListBox1.List(i) & " already exist"
End If
End If
Next i

isabelle

Le 2014-05-21 12:35, wkwells a écrit :
I have a workbook that I want to be able to add worksheets to it by checking selections in a MultiSelect Listbox,
and I want the Tab Name to be the same as the Name selected in the MultiSelect Listbox.
I am stumped, I figured how to print sheets from a MultiSelect Box and even delete worksheets, but adding them has my puzzled.

Thank you in advance for any help.

WKWells



--
Posted by Mimo Usenet Browser v0.2.5
http://www.mimousenet.com/mimo/post




All times are GMT +1. The time now is 11:53 AM.

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