Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default setting a copied worksheet

Hello,

This works for me:
Set MyWorksheet = Worksheets.Add

This doesn't:
Set MyWorksheet = Worksheets("Sheet1").Copy

Is there a way to do the set and copy on one line or do I copy and then set
on the next line?

Thanks,

Doug Glancy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default setting a copied worksheet

Doug,

The Copy method doesn't return anything, so you can't set a
variable to its result. You need two lines of code

Dim MyWorksheet As Worksheet
Worksheets("SHeet1").Copy after:=Worksheets(3)
Set MyWorksheet = ActiveSheet


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Doug Glancy" wrote in message
...
Hello,

This works for me:
Set MyWorksheet = Worksheets.Add

This doesn't:
Set MyWorksheet = Worksheets("Sheet1").Copy

Is there a way to do the set and copy on one line or do I copy
and then set
on the next line?

Thanks,

Doug Glancy




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default setting a copied worksheet

Thanks, Chip. That's what I had done, but your concise explanation helps me
understand it better.

Doug

"Chip Pearson" wrote in message
...
Doug,

The Copy method doesn't return anything, so you can't set a
variable to its result. You need two lines of code

Dim MyWorksheet As Worksheet
Worksheets("SHeet1").Copy after:=Worksheets(3)
Set MyWorksheet = ActiveSheet


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Doug Glancy" wrote in message
...
Hello,

This works for me:
Set MyWorksheet = Worksheets.Add

This doesn't:
Set MyWorksheet = Worksheets("Sheet1").Copy

Is there a way to do the set and copy on one line or do I copy
and then set
on the next line?

Thanks,

Doug Glancy






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
Can data be copied from one worksheet to another? TinaF[_2_] Excel Worksheet Functions 2 December 18th 08 03:50 PM
how do i restore a copied over worksheet ewj100 Excel Worksheet Functions 0 November 24th 07 01:38 AM
How to protect a worksheet from being copied to another worksheet SurvivorIT Excel Discussion (Misc queries) 3 August 31st 05 01:53 PM
Get the name of a newly copied worksheet Richard[_28_] Excel Programming 4 April 30th 04 07:37 AM
How name a copied worksheet? David Excel Programming 2 August 5th 03 11:02 PM


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