Extracting data from multiple sheets

kmc

Board Regular
Joined
Sep 5, 2005
Messages
158
Office Version
  1. 2016
Platform
  1. Windows
I am looking to pull data from the following cells B1,B7,B8,B10, & B17 in a WB that about 80 sheets and post it to a blank sheet. Destination can follow the same cells or post in A1, A2, A3 etc.

Thank you
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I wasn't completely sure how you wanted the data to be displayed in the destination, but this should give you a good start.

Code:
Sub Multi_Sheet_Data_Collect()
Dim iSheetCount, iSheet
Dim n As Long
 
iSheetCount = ActiveWorkbook.Worksheets.Count
n = 1
For iSheet = 1 To iSheetCount
Worksheets(iSheet).Activate

If ActiveSheet.Name = "Dest Page" Then
Else

Range("B1,B7,B8,B10,B17").Select
Selection.Copy
Worksheets("Dest Page").Activate
Range("A" & n).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=True
n = n + 1
End If
Next iSheet
End Sub
 
Upvote 0
Try this
Code:
Sub Test()
Dim ws As Worksheet
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Total"
For Each ws In Sheets
    ws.Range("B1,B7,B8,B10,B17").Copy Sheets("Total").Cells(1, Sheets("Total").Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Next ws
End Sub
 
Upvote 0
andiemac - got a run time error at the following:
Worksheets("Dest Page").Activate

Yahya - worked well until it hit a page with merged cells then stopped. Otherwise nice.

thank you both.
 
Upvote 0
My slightly diff approach:
Code:
Option Explicit

Sub CollectData()
Dim ws As Worksheet, NR As Long

If Not Evaluate("ISREF(Summary!A1)") Then
    Sheets.Add(Before:=Sheets(Sheets.Count)).Name = "Summary"
Else
    Sheets("Summary").Cells.Clear
End If

NR = 1

With Sheets("Summary")
    For Each ws In Worksheets
        If ws.Name <> "Summary" Then
            .Range("A" & NR).Value = ws.Range("B1").Value
            .Range("B" & NR).Value = ws.Range("B7").Value
            .Range("C" & NR).Value = ws.Range("B8").Value
            .Range("D" & NR).Value = ws.Range("B10").Value
            .Range("e" & NR).Value = ws.Range("B17").Value
            NR = NR + 1
        End If
    Next ws
End With

End Sub

The .Value method shouldn't fail when it hits merged cells.
 
Last edited:
Upvote 0
With a "slightly better" result. Thanks for reading my mind better than I did!
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,915
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top