I have the following code that works well for the static "LenderCode" reference; however, I need the macro to loop through the "LenderCode" range of "B4:B28" and run the same code for each value in the range
Sub Filter()
Dim i As Integer
Dim rngData As Range
Dim LenderCode As Range
Sheets("Data").Select
ActiveSheet.Range("a1").Select
Set rngData = Range("A1").CurrentRegion
i = Application.WorksheetFunction.Match("Reference-2", Range("A1:BZ1"), 0)
Set LenderCode = Sheets("Reference").Range("B4")
rngData.AutoFilter Field:=i, Criteria1:=LenderCode
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
End Sub
Thanks!
Ian
Sub Filter()
Dim i As Integer
Dim rngData As Range
Dim LenderCode As Range
Sheets("Data").Select
ActiveSheet.Range("a1").Select
Set rngData = Range("A1").CurrentRegion
i = Application.WorksheetFunction.Match("Reference-2", Range("A1:BZ1"), 0)
Set LenderCode = Sheets("Reference").Range("B4")
rngData.AutoFilter Field:=i, Criteria1:=LenderCode
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
End Sub
Thanks!
Ian