LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default VBA Code for Pasting Contents

Rick, thanks for the response.

The problem that I am having is that I have formulas that refrence the
original sheet1, sheet2, sheet3.

If I change the name of sheet1 (2) to sheet1, I am left with a cell refrence.

"Rick Rothstein" wrote:

Is the data from "Sheet1 (2)" replacing the data on "Sheet1" in its
entirety? If so, why copy/paste? Why not simply delete "Sheet1" and rename
"Sheet1 (2)" to "Sheet1"? Something like this maybe...

Sub ProcessDuplicateSheets()
Dim WS As Worksheet, BaseName As String
Application.DisplayAlerts = False
For Each WS In Worksheets
If WS.Name Like "* (2)" Then
BaseName = Split(WS.Name, " (2)")(0)
Worksheets(BaseName).Delete
WS.Name = BaseName
End If
Next
Application.DisplayAlerts = True
End Sub

Note: The changes made by this macro cannot be undone, so make sure to test
it out on a copy of your workbook.

--
Rick (MVP - Excel)



"Curt" wrote in message
...
I would like a VBA code that pastes the contents of a duplicate sheet into
it's corresponding orginal sheet.

For example, paste of "Sheet1 (2)" into "Sheet1".

Please do this for all sheets with duplicate names. You do not have to
worry about there ever being more than one duplicate. There will never be
a
"Sheet1 (3)".

After this is done, I would like a separate code that deletes all
duplicate
sheets.

For example, after pasting "Sheet1 (2)" into "Sheet1", delete "Sheet1 (2).


thanks,

Curt


.

 
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
Cell contents get cut off when pasting Annabelle4876 Excel Discussion (Misc queries) 6 August 12th 08 10:34 PM
Pasting Tables together in Excel - Contents get Cut off Annabelle4876 Excel Discussion (Misc queries) 0 May 21st 08 06:28 PM
Problems with Pasting Array contents in cells Patrick Excel Programming 2 September 20th 07 09:02 AM
Help in Pasting from 1 workbook to another in code Gary Excel Programming 2 January 9th 06 08:43 AM
Copying and pasting cell contents Gazza Excel Programming 2 June 1st 05 05:04 PM


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