Hello Natman,
This is confusing and considerably different from your opening few posts. You no longer have J1 and Q1 as the drop downs as previously stated but have a number of drop downs in ranges("M2:M7") and "X2:X7" with the criteria (Columns R and AC) calculated by a formula.
Before we take this any further, test the following code for yourself to see if the results are what you were hoping for. Please note that, for now, it is hard coded to work only on M2 and R2. Change the values in both ranges a number of times to satisfy yourself that the results are correct.
VBA Code:
Option Explicit
Sub Test()
Dim ws As Worksheet, wsM As Worksheet
Dim sVal As String
Set wsM = Sheets("Master")
Set ws = Sheets(Range("M2").Value) '---->Hard coded for now.
sVal = wsM.[R2].Value '---->Hard coded for now.
Application.ScreenUpdating = False
wsM.[A12].CurrentRegion.Offset(1).Clear
With ws.[A12].CurrentRegion
.AutoFilter 1, sVal
.Offset(1).Copy wsM.Range("B" & Rows.Count).End(3)(2)
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub
In each of the source sheets (U1-->U5), you will need to place a heading of some sort (perhaps "Criteria"?) in cell A12 to ensure that the filter works correctly. DO NOT leave it blank.
Let us know what you think.
Cheerio,
vcoolio.