LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
gizmo
 
Posts: n/a
Default Ron de Bruin Copy2 Macro - troubleshooting

Hi guys,

I've looked for a macro that could merge all the worksheets (range) from the
open workbook into one new sheet.
Surfing through newsgroup archives, I've found several links to the
following page of Ron

http://www.rondebruin.nl/copy2.htm

with several excellent exemples. However, they seem not to work for me.
Here's the exact code I've put under Alt+F11

----
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Sub Test1()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long

On Error Resume Next
If Len(ThisWorkbook.Worksheets.Item("Master").Name) = 0 Then
On Error GoTo 0
Application.ScreenUpdating = False
Set DestSh = Worksheets.Add
DestSh.Name = "Master"
For Each sh In ThisWorkbook.Worksheets
If sh.Name < DestSh.Name Then
Last = LastRow(DestSh)
sh.Range("A1:C5").Copy DestSh.Cells(Last + 1, "A")
DestSh.Cells(Last + 1, "D").Value = sh.Name
End If
Next
Cells(1).Select
Application.ScreenUpdating = True
Else
MsgBox "The sheet Master already exist"
End If
End Sub

----

What I get is just the name "Sheet1" in D1 (even if there is no such name in
the whole workbook).
Maybe this is due to the fact that I registered this macro in "Personal.xls"
(in order to keep the macro accessible for all workbooks)... But the
"Master" sheet is created in the "normal" data workbook, so there is
something I don't understand.

Do you have any idea how to get out of this?

Thanks a lot for any suggestion!
Gizmo


 
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't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM
how do I step thru a macro for troubleshooting ? chrisq Excel Discussion (Misc queries) 1 January 11th 05 07:27 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


All times are GMT +1. The time now is 10:04 PM.

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"