LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default sheet name change

Hi all.
I've got a macro that copies a worksheet from a template workbook, and
provides a name of my choosing.
More frequently of late, the macro is changing the name of an existing
hidden worksheet to match the name that I choose, instead of the newly added
worksheet. I know that because I'd check the name to ensure it didn't exist
beforehand.

Below is the full macro.
-------------------------------------------------------

Sub MkNewABSTWkSht(control As IRibbonControl)

Dim WkBkName As String, WkBkName1 As String
Dim ShtCnt As Integer, TmpltWB As Workbook

Workbooks.Application.ScreenUpdating = False

Workbooks.Open Filename:= _
"C:\Documents and Settings\sbuckley\Application Data\Microsoft\Templates\TR
Claim Book.xltx" _
, Editable:=True
Set TmpltWB = ActiveWorkbook

WkBkName = InputBox(prompt:="enter workbook name of where to copy
worksheet", Title:="Copy worksheet to existing workbook")
If Len(WkBkName) = 0 Then Exit Sub
WkBkName1 = WkBkName & ".xlsx"
Workbooks(WkBkName1).Activate
ShtCnt = ActiveWorkbook.Sheets.Count
TmpltWB.Activate
Sheets("Tab # ").Select
Sheets("Tab # ").Copy after:=Workbooks(WkBkName1).Sheets(ShtCnt)

NewNm = InputBox(prompt:="What is the sheet number you want to call this
worksheet?", Title:="New Abstract Worksheet Name")

Sheets(Sheets.Count).Name = NewNm


TmpltWB.Activate

TmpltWB.Close SaveChanges:=False
'make some additions to this which will copy the headers of the last
abstract worksheet.
'the goal being to copy the Decreed owner's name and the successor if any,
as well as the claim #
' and the decree book page #.



'When all done...
Set TmpltWB = Nothing
End Sub

--------------------------------------------

How can I fix this from continuing to happen?
Thank you.

 
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
how to change formula in shared sheet without loss of change histo DCE Excel Worksheet Functions 1 July 23rd 08 05:09 PM
Change workbook sheet reference using cell A1 to change a vairable Reed Excel Worksheet Functions 4 January 20th 05 07:15 PM
How to record a sheet change showing row column sheet name and date? Simon Lloyd[_584_] Excel Programming 0 October 6th 04 12:57 PM
How to record a sheet change showing row column sheet name and date? Simon Lloyd[_583_] Excel Programming 0 October 6th 04 10:32 AM
How to record a sheet change showing row column sheet name and date? Simon Lloyd[_578_] Excel Programming 0 October 5th 04 12:06 PM


All times are GMT +1. The time now is 10:06 AM.

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"