Consolidation macro - specfic rows from multiple worksheets based on set criteria into a master

jsbaker88

New Member
Joined
Sep 27, 2012
Messages
7
Hi

I have 10 sheets and 1 master. Each of the 10 sheets represents a set of activity from one particular client which is being compared against our bookings for the day for accuracy and completeness (a rec..). If data matches, our reference is added to column B of each sheet. If there is a mismatch or something is missing, each sheet flags our staff to check the booking.

Now, we are planning to have many more clients so it will be much easier having one master summary sheet. Column headings A-H from each sheet are the same as the master. I would like a macro which populates a 'Breaks tab', taking data in these columns whereby cell in column B (from B2 down) from each sheet contains "check". Once it finds check that row should be added to the master. Each sheet has a different number of rows populated and blanks.

Praying someone can help as I'm a VBA virgin...I know what I want just no idea how to get it.

Thanks
James
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Welcome to the board. Try:
Code:
Sub Compile_Recs()

Dim i as Long, j as Long
Dim Master_Wks as Worksheet
Set Master_Wks = Sheets("Master")

Application.ScreenUpdating = false

For i = 1 to Worksheets.Count
  With Sheets(i)
    If .AutoFilterMode Then .AutoFilterMode = False
    If .Name <> Master_Wks.Name Then
      j = .Range("A" & Rows.Count).End(xlUp).Row
      With .Range("A1:H" & j)
        .AutoFilter
        .AutoFilter Filed:=2, Criteria1:="Check"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy _
        Destination:=Master_Wks.Range("A" & Rows.Count).End(xlUp).Offset(1)
        .AutoFilterMode = False
      End With
    End if
  End with
Next i

Master_Wks.Select

With Application
  .CutCopyMode = False
  .ScreenUpdating = True
End With

End Sub
End Sub

[/code]
 
Upvote 0
Thank you...and sorry if this is obvious...

I get a complile error: sub or function not defined, highlighting AutoFilter under with .Range

Any ideas?
 
Upvote 0
My error - typo, I didn't test it myself! In red is the change but try:
Rich (BB code):
Sub Compile_Recs()

Dim i as Long, j as Long
Dim Master_Wks as Worksheet
Set Master_Wks = Sheets("Master")

Application.ScreenUpdating = false

For i = 1 to Worksheets.Count
  With Sheets(i)
    If .AutoFilterMode Then .AutoFilterMode = False
    If .Name <> Master_Wks.Name Then
      j = .Range("A" & Rows.Count).End(xlUp).Row
      With .Range("A1:H" & j)
        .AutoFilter
        .AutoFilter Field:=2, Criteria1:="Check"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy _
        Destination:=Master_Wks.Range("A" & Rows.Count).End(xlUp).Offset(1)
        .AutoFilterMode = False
      End With
    End if
  End with
Next i

Master_Wks.Select

With Application
  .CutCopyMode = False
  .ScreenUpdating = True
End With

End Sub
 
Upvote 0
thank you, still getting an error on the " If .Name <> Master_Wks.Name Then" saying undefined.. wish I was better at all this!
 
Upvote 0
No idea what's causing that, but instead, try:
Rich (BB code):
Sub Compile_Recs()

Dim i as Long, j as Long
Dim Master_Wks as Worksheet
Set Master_Wks = Sheets("Master")

Application.ScreenUpdating = false

For i = 1 to Worksheets.Count
  With Sheets(i)
    If .AutoFilterMode Then .AutoFilterMode = False
    If .Name <> "Master" Then
      j = .Range("A" & Rows.Count).End(xlUp).Row
      With .Range("A1:H" & j)
        .AutoFilter
        .AutoFilter Field:=2, Criteria1:="Check"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy _
        Destination:=Master_Wks.Range("A" & Rows.Count).End(xlUp).Offset(1)
        .AutoFilterMode = False
      End With
    End if
  End with
Next i

Master_Wks.Select

With Application
  .CutCopyMode = False
  .ScreenUpdating = True
End With

End Sub
As before, change in red
 
Upvote 0

Forum statistics

Threads
1,215,385
Messages
6,124,626
Members
449,174
Latest member
Anniewonder

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