Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Get the name of a newly copied worksheet

You have to make the hidden worksheet "Invoice Template" visible first,
before you can copy it (at least in Excel 2000 SP-3). You might also have to
copy the worksheet, then Set newSheet in a separate statement following the
statement that copies the worksheet.

Set wsTemplate = Worksheets("Invoice Template")

With wsTemplate
.Visible = xlSheetVisible 'Make Invoice Template visible.
.Copy Befo=Worksheets(1)
'newSheet is now Sheet1; previous Sheet1 should now be Sheet2.
Set newSheet = Worksheets(1)
.Visible = xlSheetHidden
End With

With newSheet
'Remaining code here.
End With

Also, the .Select statement after the "With newSheet" should probably be
..Activate
Single step through your code and verify these object variables in the Local
window as you go.
(You "Select" ranges, but you "Activate" worksheets and the activecell.)
--
Regards,
Bill


"Richard" wrote in message
news:32akc.42981$0u6.7133357@attbi_s03...
I am trying to copy a worksheet then make it active as shown in the code

below, but the Set command
does not work. Is this the correct way to grab the identity of a newly

copied worksheet? The
worksheet "Invoice Template" is hidden, so that's why the ".Visible"

statement.

Set newSheet = Worksheets("Invoice Template").Copy befo=Worksheets(1)

With newSheet
.select
.Visible = xlSheetVisible

result = InputBox("Enter a name for your new invoice", "Name your

invoice")
If result < "" Then
.Name = result
Else
.Name = "Invoice - " & Format(Date, "mmm_d_yyyy")
End If
end with


Thank you, Richard



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
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 04:24 PM
What's the easiest way to relink sheets to a newly copied master. Christina Excel Worksheet Functions 0 November 7th 07 07:00 PM
Referencing a newly created worksheet Charyn Excel Worksheet Functions 2 May 2nd 05 04:13 AM
How do I return to newly created worksheet? JJ[_5_] Excel Programming 3 December 29th 03 08:36 PM
Add Hyperlink to newly added worksheet? onliner Excel Programming 3 August 13th 03 02:04 AM


All times are GMT +1. The time now is 08:41 AM.

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

About Us

"It's about Microsoft Excel"