Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a workbook that will contain variable number of sheets and the sheets
names are numerical but not necessarily consecutive. I am trying to write a macro that will copy a template sheet and move it to the second last sheet in the workbook ("Template" sheet) is the final sheet. As mentioned, the new sheet will have a numerical name (i.e. "15"). Any help is appreciated as I just can't get my head around this. Thanks in advance, Brad |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim i As Long, wks As Worksheet, lngMax As Long For Each wks In Worksheets If IsNumeric(wks.Name) Then If CLng(wks.Name) lngMax Then lngMax = CLng(wks.Name) Next i = Worksheets.Count Worksheets("Template").Copy Befo=Worksheets(i) Worksheets(i).Name = CStr(lngMax + 1) End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Brad K." wrote in message ... I have a workbook that will contain variable number of sheets and the sheets names are numerical but not necessarily consecutive. I am trying to write a macro that will copy a template sheet and move it to the second last sheet in the workbook ("Template" sheet) is the final sheet. As mentioned, the new sheet will have a numerical name (i.e. "15"). Any help is appreciated as I just can't get my head around this. Thanks in advance, Brad |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Move or copy sheet | Excel Discussion (Misc queries) | |||
a formula or sheet you want to move or copy contains the name xxx | Excel Discussion (Misc queries) | |||
move or copy sheet | Excel Worksheet Functions | |||
Copy Sheet and move to end | Excel Discussion (Misc queries) | |||
How do I move or copy more then one sheet at a time | Excel Worksheet Functions |