Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default sheet builder macro

I once was given a macro in this forum which, once clicked, gave me a
verticle column of sheet names in the active workbook in the active sheet. I
find it very useful, but I'd like to see if someone can help me with what
amounts to the converse of that.

I'd like to have a sheet with a verticle listing of names in column A which
designates the sheet names I'd like the active workbook to have. In other
words, I'd like to assign a macro to a button which will create the
additional tabs based on the list in the active sheet in column A.

Any help will be greatly appreciated.

tia,
Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default sheet builder macro

Try this Macro...
Attach it to the button
Cell(A1) contains the Title Cells(A2,A3...) contain Sheet Names to be added

Sub AndrewMacro1()
Dim L As Integer
thisSht = ActiveSheet.Name
For L = 1 To 10 ' Max number of sheets to add
'this can be set as high as you like
Sheets(thisSht).Select
Cells(L + 1, 1).Select ' Select Next Cell down
If Selection.Value = "" Then Exit For
ShtName = Selection.Value
Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = ShtName
Next L
MsgBox "Added " + Str(L - 1) + " Worksheets"
End Sub


HTH
Andrew

"Dave Breitenbach" wrote in
message ...
|I once was given a macro in this forum which, once clicked, gave me a
| verticle column of sheet names in the active workbook in the active sheet.
I
| find it very useful, but I'd like to see if someone can help me with what
| amounts to the converse of that.
|
| I'd like to have a sheet with a verticle listing of names in column A
which
| designates the sheet names I'd like the active workbook to have. In other
| words, I'd like to assign a macro to a button which will create the
| additional tabs based on the list in the active sheet in column A.
|
| Any help will be greatly appreciated.
|
| tia,
| Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default sheet builder macro

Public Sub AddSheets()
Dim rngNames As Range
Dim rngCurrent As Range
Dim wks As Worksheet
Dim wksNew As Worksheet

Set wks = ActiveSheet
Set rngNames = wks.Range(wks.Range("A2"), wks.Cells(Rows.Count,
"A").End(xlUp))
For Each rngCurrent In rngNames
If Not (SheetExists(rngCurrent.Value)) Then
Set wksNew = Worksheets.Add
wksNew.Name = rngCurrent.Value
End If
Next rngCurrent
Exit Sub

End Sub

Public Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function

--
HTH...

Jim Thomlinson


"Dave Breitenbach" wrote:

I once was given a macro in this forum which, once clicked, gave me a
verticle column of sheet names in the active workbook in the active sheet. I
find it very useful, but I'd like to see if someone can help me with what
amounts to the converse of that.

I'd like to have a sheet with a verticle listing of names in column A which
designates the sheet names I'd like the active workbook to have. In other
words, I'd like to assign a macro to a button which will create the
additional tabs based on the list in the active sheet in column A.

Any help will be greatly appreciated.

tia,
Dave

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default sheet builder macro

This is terrific. Thanks! One question. What is the necessity of A1 as a
title? I dont see where it is used. I shifted the names down to starting in
a2 as that gets the result I wanted.

thanks again,
Dave

"Andrew" wrote:

Try this Macro...
Attach it to the button
Cell(A1) contains the Title Cells(A2,A3...) contain Sheet Names to be added

Sub AndrewMacro1()
Dim L As Integer
thisSht = ActiveSheet.Name
For L = 1 To 10 ' Max number of sheets to add
'this can be set as high as you like
Sheets(thisSht).Select
Cells(L + 1, 1).Select ' Select Next Cell down
If Selection.Value = "" Then Exit For
ShtName = Selection.Value
Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = ShtName
Next L
MsgBox "Added " + Str(L - 1) + " Worksheets"
End Sub


HTH
Andrew

"Dave Breitenbach" wrote in
message ...
|I once was given a macro in this forum which, once clicked, gave me a
| verticle column of sheet names in the active workbook in the active sheet.
I
| find it very useful, but I'd like to see if someone can help me with what
| amounts to the converse of that.
|
| I'd like to have a sheet with a verticle listing of names in column A
which
| designates the sheet names I'd like the active workbook to have. In other
| words, I'd like to assign a macro to a button which will create the
| additional tabs based on the list in the active sheet in column A.
|
| Any help will be greatly appreciated.
|
| tia,
| Dave



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default sheet builder macro

Dont Need A1 to have title,
Change Cells(L + 1, 1).Select ' Select Next Cell down
to: Cells(L , 1).Select ' Select Next Cell down
if you dont have a title in..!

Happy Excelling..!
Andrew

"Dave Breitenbach" wrote in
message ...
| This is terrific. Thanks! One question. What is the necessity of A1 as
a
| title? I dont see where it is used. I shifted the names down to starting
in
| a2 as that gets the result I wanted.
|
| thanks again,
| Dave
|
| "Andrew" wrote:
|
| Try this Macro...
| Attach it to the button
| Cell(A1) contains the Title Cells(A2,A3...) contain Sheet Names to be
added
|
| Sub AndrewMacro1()
| Dim L As Integer
| thisSht = ActiveSheet.Name
| For L = 1 To 10 ' Max number of sheets to add
| 'this can be set as high as you like
| Sheets(thisSht).Select
| Cells(L + 1, 1).Select ' Select Next Cell down
| If Selection.Value = "" Then Exit For
| ShtName = Selection.Value
| Sheets.Add After:=Worksheets(Worksheets.Count)
| ActiveSheet.Name = ShtName
| Next L
| MsgBox "Added " + Str(L - 1) + " Worksheets"
| End Sub
|
|
| HTH
| Andrew
|
| "Dave Breitenbach" wrote in
| message ...
| |I once was given a macro in this forum which, once clicked, gave me a
| | verticle column of sheet names in the active workbook in the active
sheet.
| I
| | find it very useful, but I'd like to see if someone can help me with
what
| | amounts to the converse of that.
| |
| | I'd like to have a sheet with a verticle listing of names in column A
| which
| | designates the sheet names I'd like the active workbook to have. In
other
| | words, I'd like to assign a macro to a button which will create the
| | additional tabs based on the list in the active sheet in column A.
| |
| | Any help will be greatly appreciated.
| |
| | tia,
| | Dave
|
|
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Query Builder Courtneyf04 Excel Discussion (Misc queries) 1 March 28th 08 09:49 PM
Permutation Builder Stephen Excel Discussion (Misc queries) 3 February 6th 08 07:38 PM
Answer in function builder but not in worksheet Ms. Z Excel Worksheet Functions 2 December 1st 06 05:36 PM
Report Builder Add-In Eva Shanley[_2_] Excel Programming 1 September 9th 04 04:39 PM
Registering function WITHOUT it appearing in the expression builder Aaron Queenan Excel Programming 0 August 7th 03 05:12 PM


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"