Macro sheet replication and numbering

shaun111

New Member
Joined
May 12, 2008
Messages
30
Hi,

Could you please help me with a piece of code which I can add to a form button to achieve the following:

1. Replicate a "super hidden sheet" invoice template once the form button is pressed. i.e add a copy of the super hidden sheet to the end of the existing sheets.

a. The replicated template will need to have as its sheet name, the code of the sheet before it plus one. For example: the workbook has the sheets, tabs: 1960, 1961 and 1962. Once the replicate sheet is added its tab will reflect 1963.

b. Is there an equation or a piece of code that will return the name of the sheet in a particular reference cell within the sheet. For example once 1963 is created cell B1 within 1963 will return "1963" as the invoice number?

Hope that is not too confusing? :confused:

Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Something like this should do that

Code:
Sub test()
Application.ScreenUpdating = False
Sheets("Sheet1").Visible = xlSheetVisible
Sheets("Sheet1").Copy after:=Sheets(Sheets.Count)
Sheets("Sheet1").Visible = xlSheetVeryHidden
With ActiveSheet
    .Name = CInt(Sheets(Sheets.Count - 1).Name) + 1
    .Range("B1").Value = .Name
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top