Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Macro to copy worksheet

I have a Summary worksheet that updates daily using several vlookup formulas.
I created a macro that would archive this information. In the macro, I
first make a copy of the summary worksheet. Then on the copy, I copy/paste
special the values and formats onto the worksheet to make sure that I get
only the values and not the vlookup formulas.

The problem is that when I go to run the macro the next day, it creates a
copy of the wrong worksheet. I need it to create a copy of the Summary
worksheet. Here is the code for the macro.


Sub Archive()
'
' Archive Macro
' Macro recorded 6/12/2007 by Nekiah V. Jackson
'
' Keyboard Shortcut: Ctrl+b
'
Sheets("Summary").Select
Sheets("Summary").Copy Befo=Sheets(5)
Sheets("Summary (2)").Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D11").Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to copy worksheet

Your code looks like it always copies the worksheet named Summary.

Maybe you meant that it it always copy|pastespecial values against the wrong
sheet.

Option Explicit
Sub Archive2()

with activeworkbook
'put it at the end?
.Sheets("Summary").Copy _
After:=.Sheets(.sheets.count)
end with

with activesheet 'the sheet just created
.cells.copy
.cells.pastespecialPaste:=xlPasteValues
end with

End Sub

This doesn't rely on the name of the new sheet--it just uses the newly activated
sheet (the one that was just created by the .copy).

clarknv wrote:

I have a Summary worksheet that updates daily using several vlookup formulas.
I created a macro that would archive this information. In the macro, I
first make a copy of the summary worksheet. Then on the copy, I copy/paste
special the values and formats onto the worksheet to make sure that I get
only the values and not the vlookup formulas.

The problem is that when I go to run the macro the next day, it creates a
copy of the wrong worksheet. I need it to create a copy of the Summary
worksheet. Here is the code for the macro.

Sub Archive()
'
' Archive Macro
' Macro recorded 6/12/2007 by Nekiah V. Jackson
'
' Keyboard Shortcut: Ctrl+b
'
Sheets("Summary").Select
Sheets("Summary").Copy Befo=Sheets(5)
Sheets("Summary (2)").Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D11").Select
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to copy worksheet

Oops. Dropped a space character:
..cells.pastespecialPaste:=xlPasteValues
should be:
..cells.pastespecial Paste:=xlPasteValues

Dave Peterson wrote:

Your code looks like it always copies the worksheet named Summary.

Maybe you meant that it it always copy|pastespecial values against the wrong
sheet.

Option Explicit
Sub Archive2()

with activeworkbook
'put it at the end?
.Sheets("Summary").Copy _
After:=.Sheets(.sheets.count)
end with

with activesheet 'the sheet just created
.cells.copy
.cells.pastespecialPaste:=xlPasteValues
end with

End Sub

This doesn't rely on the name of the new sheet--it just uses the newly activated
sheet (the one that was just created by the .copy).

clarknv wrote:

I have a Summary worksheet that updates daily using several vlookup formulas.
I created a macro that would archive this information. In the macro, I
first make a copy of the summary worksheet. Then on the copy, I copy/paste
special the values and formats onto the worksheet to make sure that I get
only the values and not the vlookup formulas.

The problem is that when I go to run the macro the next day, it creates a
copy of the wrong worksheet. I need it to create a copy of the Summary
worksheet. Here is the code for the macro.

Sub Archive()
'
' Archive Macro
' Macro recorded 6/12/2007 by Nekiah V. Jackson
'
' Keyboard Shortcut: Ctrl+b
'
Sheets("Summary").Select
Sheets("Summary").Copy Befo=Sheets(5)
Sheets("Summary (2)").Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D11").Select
End Sub


--

Dave Peterson


--

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
macro to copy worksheet vitorjose Excel Worksheet Functions 0 January 25th 07 01:01 AM
create a macro to copy a worksheet into another Sean Excel Discussion (Misc queries) 7 October 18th 06 10:19 PM
Macro copy and paste = blank worksheet efface Excel Discussion (Misc queries) 1 April 27th 06 09:52 PM
Want macro to select & copy cells from a different worksheet RocketRod Excel Discussion (Misc queries) 5 February 28th 06 12:53 PM
I need help with a macro which will copy a worksheet and.. Greegan Excel Worksheet Functions 2 July 29th 05 11:48 PM


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