Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Copying sheet tab "x" number of times

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JDaywalt - 29 Nov 2007 18:37 GMT
I have a sheet tab that is named "MASTER".  I am trying to write a macro that
will copy this sheet tab multiple times based upon the value in cell A1 of a
sheet tab called "QTY".  For example, if the value on the QTY tab is "4", the
"MASTER" tab will be copied 4 times---always placing the new tab at the "end"
of the sheet tab block.   Can someone help with this?
sebastienm - 29 Nov 2007 18:45 GMT
Hi,

Use the CopyTabN sub from this thread:
<http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public
.excel.programming&mid=5bc775be-d632-41a3-8306-03c5d6cd9f90
>

and call it as:

Sub Test()
  CopyTabN Thisworkbook.Worksheets("MASTER") _
        , CLng(Thisworkbook.Worksheets("QTY").Range("A1").value)
End Sub

Signature

Regards,
Sébastien
<http://www.ondemandanalysis.com>

> I have a sheet tab that is named "MASTER".  I am trying to write a macro that
> will copy this sheet tab multiple times based upon the value in cell A1 of a
> sheet tab called "QTY".  For example, if the value on the QTY tab is "4", the
> "MASTER" tab will be copied 4 times---always placing the new tab at the "end"
> of the sheet tab block.   Can someone help with this?
Dale Fye - 29 Nov 2007 18:49 GMT
Since I'm relatively new to the Excel object model, I usually start out by
creating a macro to do what I want (in this case, copy the Master worksheet
to the end of the workbook).   Then I'll add the code I need around that.  
Something like:

Public Sub CopySheet

   Dim intLoop as integer

   intLoop = 1
   Do While intLoop <= ActiveWorkbook.Sheets("SheetName").Cells("A1")
       
        'put your copy code in here
        'you might want to add some code that changes the names of the
        'copy by appending the intLoop value to the word "Copy"

        intLoop = intLoop + 1
   Loop

End Sub

HTH
Dale        
Signature

Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.

> I have a sheet tab that is named "MASTER".  I am trying to write a macro that
> will copy this sheet tab multiple times based upon the value in cell A1 of a
> sheet tab called "QTY".  For example, if the value on the QTY tab is "4", the
> "MASTER" tab will be copied 4 times---always placing the new tab at the "end"
> of the sheet tab block.   Can someone help with this?
Don Guillett - 29 Nov 2007 19:00 GMT
Sub addshts()
For i = 1 To InputBox("Enter sheets desired") - 1
Sheets("Master").Copy After:=Sheets("Master")
Next i
End Sub
Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

>I have a sheet tab that is named "MASTER".  I am trying to write a macro
>that
[quoted text clipped - 5 lines]
> "end"
> of the sheet tab block.   Can someone help with this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.