Merging Worksheets

  • Thread starter Thread starter Sheila Wilson
  • Start date Start date
S

Sheila Wilson

I have 200+ workbooks, each with 3 worksheets. I need to
merge the data onto 1 worksheet for each workbook.

Can anyone help me with a quick method/shortcut

TIA
 
Hi Sheila
but I'm afraid I don't use VB

If you don't want to use VBA code in Excel then you have a
lot of work to do.

Why don't you want to use VBA??
 
Hi

http://www.mvps.org/dmcritchie/excel/getstarted.htm
See David McRitchie's site if you just started with VBA

Let's try to merge all sheets in a workbook in one sheet.
Open one workbook with the 3 sheets to try

Where do I place the code and the functions?
1. Alt-F11
2. Insert>Module from the Menubar
3. Paste the Code there (see below)
4. Alt-Q to go back to Excel
5. Alt-F8 to run the sub

Copy this in the module

Sub Test3()
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.UsedRange.Copy DestSh.Cells(Last + 1, "A")
'Instead of this line you can use the code below to copy only the values
'or use the PasteSpecial option to paste the format also.


'With sh.UsedRange
'DestSh.Cells(Last + 1, "A").Resize(.Rows.Count, _
'.Columns.Count).Value = .Value
'End With


'sh.UsedRange.Copy
'With DestSh.Cells(Last + 1, "A")
' .PasteSpecial xlPasteValues, , False, False
' .PasteSpecial xlPasteFormats, , False, False
' Application.CutCopyMode = False
'End With

End If
Next
Cells(1).Select
Application.ScreenUpdating = True
Else
MsgBox "The sheet Master already exist"
End If
End Sub

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


Post back after you try this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top