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: 102
Default Code to copy worksheet

Hi
I'm sorry in advance - I'm a novice and I am stuck with re-writing the
following code without using a hard code worksheet name, or "current
worksheet" or "active worksheet" or "selection"... (I must avoid using these
words as they are apparently causing problems macros assigned to buttons)

The code needs to:
- make a copy of the current worksheet - whose name appears in cell BP8
- put the copy into a separate workbook
- select the named range "PlanCPTrange" on the copied worksheet (only) and
paste special as values
- select all buttons on the copied worksheet (only) and delete them
- select cell A1 (without using the word "select"
I tried to do this myself, but failed:

Sub CopyPlan()
Dim mySheet As Worksheet (?????)
Dim DestSheet As Worksheet (????)

Set mySheet = Range("BP8").Value 'mySheet worksheet name is quoted in BP8
on the current worksheet
Set DestSheet = ???? 'the name of the copied mySheet i.e. if BP8 = "Test"
then it will be "Test (2)"

With mySheet
Copy After:=Workbooks(????).Sheets(1) 'how to copy mySheet worksheet
into a new workbook
End With

With DestSheet.Range("PlanCPTrange")
Cells.Copy
Cells.PasteSpecial Paste:=xlValues
End With

With Destsheet.Buttons
.Delete
End With

End Sub

--
Thank for your help
BeSmart
 
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
Copy worksheet without code behind clara Excel Programming 2 May 4th 07 09:01 PM
copy worksheet without code behind clara Excel Programming 1 May 3rd 07 08:43 PM
Copy VB code from one worksheet to another using VBE eDude Excel Programming 2 October 19th 06 04:25 AM
Copy Worksheet with Code Bill[_30_] Excel Programming 1 September 28th 05 10:21 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM


All times are GMT +1. The time now is 02:17 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"