Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default worksheet copy problem

I have a workbook with a number of hidden sheets

When I copy one of my hidden sheets I do not necessarily no the name of the new sheet because of duplicates etc

I do not no the index number of the sheet because when I put it after sheets.count it goes after the last visible sheet

I would love to simply know the codename of the new sheet but again there can be "holes" in the codename numbering because of deletions

How can I copy a sheet and know its name, codename and index afterward?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default worksheet copy problem

You might not be able to get the codename after you copy the sheet, but you may
not actually need it either.

If the VBE was opened, the codename was returned. If the VBE was never opened,
then the codename was returned as "".

Option Explicit
Sub testme()

Dim wkbk1 As Workbook
Dim wkbk2 As Workbook
Dim Wks As Worksheet

Set wkbk1 = Workbooks("book1.xls")
Set wkbk2 = Workbooks("book2.xls")

wkbk1.Worksheets(3).Copy _
after:=wkbk2.Worksheets(wkbk2.Worksheets.Count)
Set Wks = ActiveSheet

MsgBox Wks.Name & vbLf & Wks.CodeName & vbLf & Wks.Index

End Sub


But after you copy a worksheet, it's the activesheet. You can set an object
variable (wks in my example) to that new activesheet and do lots of stuff to it.


dan wrote:

I have a workbook with a number of hidden sheets.

When I copy one of my hidden sheets I do not necessarily no the name of the new sheet because of duplicates etc.

I do not no the index number of the sheet because when I put it after sheets.count it goes after the last visible sheet.

I would love to simply know the codename of the new sheet but again there can be "holes" in the codename numbering because of deletions.

How can I copy a sheet and know its name, codename and index afterward?


--

Dave Peterson

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
Excel 2007 Copy Worksheet Problem webermis Excel Discussion (Misc queries) 0 February 23rd 10 04:38 PM
Copy Worksheet wont copy objects. Lincoln De Kalb Excel Worksheet Functions 7 January 12th 09 10:30 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
Worksheet copy problem - local names Jack Sheet Excel Discussion (Misc queries) 2 December 2nd 04 10:02 AM
worksheet copy problem jim apostolidis Excel Programming 1 October 16th 03 01:38 PM


All times are GMT +1. The time now is 05:21 PM.

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"