View Single Post
  #2   Report Post  
Sepeteus Jedermann Sepeteus Jedermann is offline
Junior Member
 
Posts: 18
Post

Quote:
Originally Posted by kaine View Post
I have been working on this for a few days now and have had zero luck...

what I am trying to do is create a macro or formula to create and name new work sheet's. I am needing it to reference a number in a cell on the master page of the report and create and name that number of sheet's or tab's.

like if
( A1=5 it would create 5 sheet's named test#1,test#2,test#3,ect... )

and I would like to ad a template to it later but need to get it working first.
Hi,

Put following code to your workbooks VBA-module.



Sub TestSheets()
Dim TblAdd As Integer
Dim X As Integer

TblAdd = Range("A1").Value
For X = 1 To TblAdd
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "Test" & X
Next X
End Sub

to see the module you can do the following things :

1 ) open the workbook

2 ) press ALT + F11

3 ) if you can not see any modules there, select INSERT - MODULE

4 ) paste above 10 rows to module window and save ( CTRL + S )

5 ) switch to the normal Excel view

6 ) put some number value to cell A1 in active sheet

7 ) press ALT + F8 and run macro named Sub TestSheets()

8 ) new worksheets should appear to the right end of worksheet tabs


I hope this will help you a bit.

***