+ Reply to Thread
Results 1 to 8 of 8

Extract multiple sheets data into one sheet

Hybrid View

  1. #1
    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

    Can you use this?

    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(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
                Range(ActiveCell, ActiveCell.offset(3)).Copy ws.Range("C" & i)
            End If
            Set rng = Nothing
        ws.Activate
        Set rng = Sheets(y).Rows(1).Find(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
                Range(ActiveCell, ActiveCell.offset(3)).Copy ws.Range("D" & i)
            End If
            Set rng = Nothing
            ws.Activate
        Set rng = Sheets(z).Rows(1).Find(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
                Range(ActiveCell, ActiveCell.offset(3)).Copy ws.Range("E" & i)
            End If
            Set rng = Nothing
    ws.Activate
    Next i
    
    End Sub

  2. #2
    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,

    This great, it does exactly what I require. I have a small issue with the data content, which is, in Aug, June..etc worksheet there values under bs, cm...etc, which , are calculated using 'sum' formula and when I run the code, in the 'monthly' worksheet, the values get extracted as '#Ref'. Is this something easy to fix/or add in the code. Apology for the last minute trouble.

    if you require further detailed example, on the above request, please do let me know.

    Many thanks for your time.

  3. #3
    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(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.Range(Cells(i, "C"), Cells(i + 3, "C")).Value = Range(ActiveCell, ActiveCell.offset(3)).Value
            End If
            Set rng = Nothing
        ws.Activate
        Set rng = Sheets(y).Rows(1).Find(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.Range(Cells(i, "D"), Cells(i + 3, "D")).Value = Range(ActiveCell, ActiveCell.offset(3)).Value
            End If
            Set rng = Nothing
            ws.Activate
        Set rng = Sheets(z).Rows(1).Find(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.Range(Cells(i, "D"), Cells(i + 3, "D")).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