Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Copy active sheet tab

I have a workbook containing several sheet tabs. I want to include code that
allows the user to replicate or 'copy' any of these sheet tabs and place the
new sheet directly to the right of the sheet they 'copied' from. For
example, let's say the sequence of existing sheet tabs is "Jones", "Smith",
and "Taylor". If a user is on "Smith" when they perform the copy, I want the
"Smith (2)" sheet to fall directly to the right of the current "Smith" sheet.
I have tried recording a macro to copy the sheet & was planning to
substitute the actual sheet name (Smith) with the more generic 'ActiveSheet'
reference, but I don't know how to adjust for the hard-coded Sheets(5) value
that appears in the last line of code-----Here is what my recorded code looks
like right now:
Sheets("Smith").Select
Sheets("Smith").Copy Befo=Sheets(5)
How can I adjust so it performs the generic "copy directly to the right"
function based on whichever active sheet I'm on at the time code is executed?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Copy active sheet tab

Just figured it out on my own -- used the following code & it worked
perfectly!!

ActiveSheet.Copy After:=ActiveSheet

"JDaywalt" wrote:

I have a workbook containing several sheet tabs. I want to include code that
allows the user to replicate or 'copy' any of these sheet tabs and place the
new sheet directly to the right of the sheet they 'copied' from. For
example, let's say the sequence of existing sheet tabs is "Jones", "Smith",
and "Taylor". If a user is on "Smith" when they perform the copy, I want the
"Smith (2)" sheet to fall directly to the right of the current "Smith" sheet.
I have tried recording a macro to copy the sheet & was planning to
substitute the actual sheet name (Smith) with the more generic 'ActiveSheet'
reference, but I don't know how to adjust for the hard-coded Sheets(5) value
that appears in the last line of code-----Here is what my recorded code looks
like right now:
Sheets("Smith").Select
Sheets("Smith").Copy Befo=Sheets(5)
How can I adjust so it performs the generic "copy directly to the right"
function based on whichever active sheet I'm on at the time code is executed?

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
Copy sheet and make new sheet active belvy123 Excel Discussion (Misc queries) 5 April 24th 08 03:33 PM
Copy active sheet to new - do no copy buttons Carlee Excel Programming 3 June 13th 07 04:33 PM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Excel Programming 0 April 6th 06 03:56 AM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Excel Programming 3 January 23rd 06 09:57 PM


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