Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Question help with macros?

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.
  #2   Report Post  
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.

***
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
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


All times are GMT +1. The time now is 09:32 PM.

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

About Us

"It's about Microsoft Excel"