Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel - Combining Worksheets

Posted on 2011-02-11
5
Medium Priority
?
306 Views
Last Modified: 2012-05-11
Hi,

I have an Excel workbook with 12 worksheets.

Other than copy/paste, is there a method to combine the rows of all 12 worksheets into one worksheet  - 13. All sheets have the same cells in the header row.

Thank you
0
Comment
Question by:tahirih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 34873526

You can do it by use of macro..Help me understand does in your worksheet you have 13 sheets only..? or there are more worksheets?

Also what is the 13th sheet callled where you want to move the data to?

I also assume that all your 12 worksheets have same amount of data..as in column headings...
0
 

Author Comment

by:tahirih
ID: 34873561
There are more worksheets - I want to combine the first 12 (or 'n' for that matter).

The 12 (n) worksheets do not have the same amount of data (they vary in the number of rows filled)

Thanks
0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 34873592

What's the worksheet name as in by what name you call them which you want to combine..?? And what is the worksheet 13 called..?
0
 

Author Comment

by:tahirih
ID: 34874036
They have varying names - not a consistent naming system (e.g. 1 - 12)

Thank you
0
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 2000 total points
ID: 34874297

You can use the following code and i have assumed all your worksheets i.e 1-12 are in order..This will do what you are looking for...

Saurabh...
Sub movemydata()
    Dim ws As Worksheet
    Dim lr As Long, cl As Long
    Dim lrw As Long
    Dim k As Long
    Dim ws1 As Worksheet
    Set ws = Sheets("13")

    Application.ScreenUpdating = False

    Sheets("1").Select

    For k = 1 To 11
        cl = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
        lr = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        On Error Resume Next
        If Err.Number = 91 Then lrw = 1
        Err.Clear
        lrw = ws.Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        Range("A1:" & Cells(lr, cl).Address).Copy ws.Range("A" & lrw + 1)

        ActiveSheet.Next.Select
    Next k





    Application.ScreenUpdating = True
End Sub

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question