VBA for Autofilter if column ontains value on another sheet

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, I am trying to work out the vba, to replace "pass" and "investment" with the cell location Sheet Instructions cell C26 and Sheet instructions C35 as these are drop down lists which can contain various options. I can find numerous examples where everything is contain on a single sheet, but not different sheets, if anyone has an example i would appreciate it.


Sheets("cases available ").Select
Cells.Select
ActiveSheet.Range("$A$:$AA$").AutoFilter Field:=11, Criteria1:= _
"=*Pass*", Operator:=xlAnd

ActiveSheet.Range("$A$:$AA$").AutoFilter Field:=27, Criteria1:= _
"=*investment*", Operator:=xlAnd

I also need to know the code, for if c26 is blank , then look at cell c32 on that sheet.

Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try
Criteria1:=Sheets("Instructions").range("C26").value
 
Upvote 0
THanks, I have tried this and am nearly there on the first part., however field 27 can have various word, i only want it to filter if it contains the word in cell c35, I have tried below and this does not work

ActiveSheet.Range("a:ab").AutoFilter Field:=8, Criteria1:= _
Sheets("instructions ").Range("c23").Value
ActiveSheet.Range("a:ab").AutoFilter Field:=11, Criteria1:= _
Sheets("instructions ").Range("c26").Value
ActiveSheet.Range("a:ab").AutoFilter Field:=27, Criteria1:="=*" & Sheets("instructions ").Range("c35") & "*"

How to i make the last line into contains "xyz"
 
Upvote 0
A simplified version of your code is
Code:
   With Sheets("cases available ").Range("a:ab")
      .AutoFilter Field:=8, Criteria1:=Sheets("instructions ").Range("c23").value
      .AutoFilter Field:=11, Criteria1:=Sheets("instructions ").Range("c26").value
      .AutoFilter Field:=27, Criteria1:="=*" & Sheets("instructions ").Range("c35") & "*"
   End With
and it works for me. What are the values you have in col AA & what are your filter values?
 
Upvote 0
my filter values are

my filter values are
C23 is a list of names
c26 is a list of status values
c35 are a list of products
Example of cell in column aa

estate investment protection

<tbody>
</tbody><colgroup><col></colgroup>

or
protection Mortgage

<tbody>
</tbody><colgroup><col></colgroup>

<tbody>
</tbody><colgroup><col></colgroup>
So there are gaps between each word and sometimes before the first word.
column AA, just combines the values in columns V-Z as i thought it would be the easiest way to filter to find the rows i want .

SO effectlvely i am looking for a filter for , name , status and any row in column AA that contains the selected product.
 
Upvote 0
How are you concatenating columns V-Z?
 
Upvote 0
In that case if you have estate investment protection in col AA and estate in C35 it should work. Try just running the autofilter on col AA & see what happens
Code:
With Sheets("cases available ").Range("a:ab")
      .AutoFilter Field:=27, Criteria1:="=*" & Sheets("instructions ").Range("c35") & "*"
End With
 
Upvote 0
Glad it's sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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