+ Reply to Thread
Results 1 to 8 of 8

Extract multiple sheets data into one sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    06-20-2014
    Location
    France
    MS-Off Ver
    2010
    Posts
    20

    Re: Extract multiple sheets data into one sheet

    Hi John,

    Apology for not getting back to you sooner. I am sorry to inform, I was unable to run the updated macro successfully. The updated macro is throwing a "run-time error 1004", when I run it on example workbook file(data_extraction_2). I believe the error is within the first for loop of the code, hence when I run the macro, I get transferred to the 'June' worksheet.

    data_extraction3.xlsm
    I have attached the same sample data with 'June' sheet showing 'sum formula' values under the 'bs, rm, cm..etc' columns and the rest of the worksheets 'july' & 'aug', have just number values. The macro is attached in the workbook example.

    Thank you very much for updating the code in your previous post.

    Many thanks for your response and time in solving the issue.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Extract multiple sheets data into one sheet

    Try:

    Sub jun22()
    Dim x As String
    Dim y As String
    Dim z As String
    Dim rng As Range
    Dim i As Long
    Dim ws As Worksheet
    
    Set ws = Sheets("monthly")
    ws.Activate
    x = ws.Cells(1, "C").Value
    y = ws.Cells(1, "D").Value
    z = ws.Cells(1, "E").Value
    For i = 3 To ws.Range("A" & Rows.count).End(3).Row Step 4
        Set rng = Sheets(x).Rows(1).Find(ws.Range("A" & i).Value, LookIn:=xlValues, Lookat:=xlWhole)
            If Not rng Is Nothing Then
                Sheets(x).Activate
                Cells(2, rng.Column).Select
                Do Until ActiveCell.Value <> ""
                    ActiveCell.offset(1).Select
                Loop
                ws.Cells(i, "C").Resize(3).Value = Range(ActiveCell, ActiveCell.offset(3)).Value
            End If
            Set rng = Nothing
        ws.Activate
        Set rng = Sheets(y).Rows(1).Find(ws.Range("A" & i).Value, LookIn:=xlValues, Lookat:=xlWhole)
            If Not rng Is Nothing Then
                Sheets(y).Activate
                Cells(2, rng.Column).Select
                Do Until ActiveCell.Value <> ""
                    ActiveCell.offset(1).Select
                Loop
                ws.Cells(i, "D").Resize(3).Value = Range(ActiveCell, ActiveCell.offset(3)).Value
    
            End If
            Set rng = Nothing
            ws.Activate
        Set rng = Sheets(z).Rows(1).Find(ws.Range("A" & i).Value, LookIn:=xlValues, Lookat:=xlWhole)
            If Not rng Is Nothing Then
                Sheets(z).Activate
                Cells(2, rng.Column).Select
                Do Until ActiveCell.Value <> ""
                    ActiveCell.offset(1).Select
                Loop
                ws.Cells(i, "E").Resize(3).Value = Range(ActiveCell, ActiveCell.offset(3)).Value
            End If
            Set rng = Nothing
    ws.Activate
    Next i
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to extract data from multiple sheets
    By somnath6309 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-07-2013, 10:18 AM
  2. Macro to Extract Data from Multiple Sheets into One Sheet
    By BillW93 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-05-2013, 10:55 AM
  3. [SOLVED] How to code a macro to extract data from multiple sheets into one sheet?
    By likeabottle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2013, 04:51 PM
  4. Data extract from multiple sheets to one
    By ASH2707 in forum Excel General
    Replies: 4
    Last Post: 03-15-2011, 06:57 AM
  5. Extract data from multiple sheets
    By jmenche in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2005, 12:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1