Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Combine Worksheets - help with Code!

Hi CherylH

Read the information on the page good
http://www.rondebruin.nl/copy2.htm

You can find the functionand instructions on the bottom of the webpage




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"CherylH" wrote in message ...
Hi all,
I need some assistance with combining worksheets. I have 89 worksheets that
have the same format (columns, headings) and need to combine these into one
large worksheet. The only difference is the actual data and the amt of
records on each.

I've looked thru the discussion boards and am trying to use code provided by
rondebruin, however when I run I receive a a compile error. Since I am by no
means a VBA expert, I have no idea what to do. Can someone look thru this
code and assist me? The field highlighted via the compile error is
LastRow(DestSh) ---see below.


Thanks in advance for any help!
Cheryl
===============================================
Sub Test2()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Dim shLast 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)
^^^^receive compile error - sub or function not
defined
shLast = LastRow(sh)

'This example copies everything, if you only want to copy
'values/formats look at the example below the first example
sh.Range(sh.Rows(2), sh.Rows(shLast)).Copy DestSh.Cells(Last +
1, "A")

End If
Next

Application.Goto DestSh.Cells(1)

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


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
combine worksheets Scrambled Excel Discussion (Misc queries) 3 July 23rd 07 11:50 PM
Combine Worksheets William@Target Excel Worksheet Functions 2 March 8th 07 09:19 PM
How to combine several worksheets Mark D. Brown, MSW Setting up and Configuration of Excel 1 January 4th 06 05:05 PM
How do I combine two worksheets in Excel? Sgreen New Users to Excel 2 July 8th 05 05:39 PM
Combine Data from 2 worksheets Krefty Excel Discussion (Misc queries) 3 January 14th 05 11:40 PM


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