• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Multiple filter ranges and multiple destination ranges in same sheet

nbuddhi

Member
Dear Team,

I have to extract some data from different ranges. Below I mentioned the different filter ranges where I put required data along with other data. search criteria range is the cell contain the filter criteria and paste range is the destination cell that filtered data to be paste.

I have attached a dummy data for better clarity. Kindly help me to create a macro to automate the process.

Thank you
nbuddhi

Filter RangeSearch Criteria RangePaste Range
C3:C100D2D3
E3:E100F2F3
E3:E100G2G3
E3:E100H2H3
E3:E100I2I3
E3:E100J2J3
E3:E100K2K3
E3:E100L2L3
E3:E100M2M3
N3:N100O2O3
N3:N100P2P3
N3:N100Q2Q3
N3:N100R2R3
N3:N100S2S3
N3:N100T2T3
N3:N100U2U3
N3:N100V2V3
N3:N100W2W3
N3:N100X2X3
N3:N100Y2Y3
Z3:Z100AA2AA3
Z3:Z100AB2AB3
Z3:Z100AC2AC3
Z3:Z100AD2AD3
Z3:Z100AE2AE3
Z3:Z100AF2AF3
Z3:Z100AG2AG3
Z3:Z100AH2AH3
Z3:Z100AI2AI3
AJ3:AJ100AK2AK3
AJ3:AJ100AL2AL3
 

Attachments

  • Dummy.xlsx
    68.4 KB · Views: 2
This isn't really helping you, it's doing your job for you.
In the attached:
A button on the sheet Before (2) in the vicinity of cell B2 which calls the following:
Code:
Sub blah()
For Each rw In Sheets("Data Ranges").Range("A2:C32").Rows
getList rw.Cells(1).Value, rw.Cells(2).Value, rw.Cells(3).Value
Next rw
End Sub

Sub getList(FilterRange, CritRange, DestnRange)
With Sheets("Before (2)")
  Set rngFilter = .Range(FilterRange)
  Crit = .Range(CritRange).Value
  Set Destn = .Range(DestnRange)
  'clear the destn range:
  Destn.Resize(100).ClearContents

  For Each cll In rngFilter.Cells
    If InStr(1, cll.Value, Crit, vbTextCompare) > 0 Then
      Destn.Value = cll.Value
      Set Destn = Destn.Offset(1)
    End If
  Next cll
End With
End Sub

A formula only solution in sheet Before Formula in row 3 (highlighted in green)
Solutions match your After sheet except for column U where I think your sheet is wrong.
 

Attachments

  • Chandoo50297Dummy.xlsm
    138.8 KB · Views: 1
Dear p45cal,

Great, it worked like charm. Many thanks for your great support.

Yes, mistakenly I have put wrong filling data in column U.

Thanks & Best Rgds,
nbuddhi
 
Dear p45cal,

Can you change the code If I need to filter only the strings begin with search criteria?

Thanks & Best Rgds,
nbuddhi
 
Code:
Change:
If InStr(1, cll.Value, Crit, vbTextCompare) > 0 Then
to
If InStr(1, cll.Value, Crit, vbTextCompare) = 1 Then

Formula:
Change the likes of:
=FILTER($E3:$E100,ISNUMBER(SEARCH(G2,$E3:$E100)),"")
to:
=FILTER($E3:$E100,IFERROR(SEARCH(G2,$E3:$E100),0)=1,"")
 
Back
Top