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: 1
Default Merge Macro Excel 2007

Hi!

I need your help. The code to merge sheets to a master sheet runs great,
however when I copy the code to the Personal.XLSB to have the macro
available to use on every workbook I’m getting an error. The line of
code is Application.Goto DestSh.Cells(1) and the error is Method ‘Goto
of object’_Application’failed. This happen even if I create a new
workbook with 3 sheets and only a few cells with information. Can you
help me please? The macro to mail the sheet works fine using the
Personal XLSB.
Thank you,
Sub Merge_Sheets()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Delete the sheet "MergeSheet" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("MergeSheet").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Add a worksheet with the name "MergeSheet"
Set DestSh = ThisWorkbook.Worksheets.Add
DestSh.Name = "MergeSheet"

'loop through all worksheets and copy the data to the DestSh
For Each sh In ThisWorkbook.Worksheets
If sh.Name < DestSh.Name Then
Last = LastRow(DestSh)

'To copy all cells with data on the sheet
sh.UsedRange.Copy DestSh.Cells(Last + 1, "A")


'This will copy the sheet name in the H column if you want
DestSh.Cells(Last + 1, "A").Value = sh.Name

End If
Next

Application.Goto DestSh.Cells(1)

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub




*** Sent via Developersdex http://www.developersdex.com ***
 
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
Performing a merge in Excel 2007 Helen Excel Discussion (Misc queries) 1 November 25th 09 11:18 AM
how do I merge two 2007 excel documents Brian Excel Discussion (Misc queries) 1 November 24th 08 10:30 PM
How to merge two chart types in Excel 2007 Justin Excel Discussion (Misc queries) 2 January 31st 08 04:58 AM
excel 2007 file merge pg New Users to Excel 1 January 4th 08 04:12 PM
Using Mail Merge in Excel 2007 Helen P Excel Discussion (Misc queries) 1 June 4th 07 06:04 PM


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