Filter based on cell value

ppleasebob

Board Regular
Joined
Dec 23, 2002
Messages
145
Board,

I want to filter a range (A18:Q2300) based on the content of cell H4 (for column A) and cell h6 (for column B).

I have spent prpbably the whole morning going through the archive looking for an answer and I know I gonna scream when one of you kind folk answer this for me.

Thanks for looking

Bob
 
Hello again Bob

Rng1 is the entire range (including column labels) - therefore assumes that you have column labels / titles in row 18.

Rng2 is the entire data range, that is this range should exclude column labels / titles.

I'm not sure what you intend on doing with the filtered data but I have assumed that if you want to copy and paste it; or delete it, then you would want to do this to the data area only and not include the column labels.

Yes, I assumed both criteria were dates. Change:
Criteria1:=CDate(rCrit1.Value)
to:
Criteria1:=rCrit1.Value

If you continue to get a mis-match then please let me know which line it debugs to (i.e. the line highlighted in yellow).
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Jon - I just copied your code and pasted it in..(right clicked the worksheet tab, view code, paste - save)

Not sure if Jon's code needs to be in a standard module to work properly? (rather than the Worksheet module)
 
Upvote 0
Jon,

Thanks for the changes, I decided to revisit Yard's formulaic solution, given the fact that the spreadsheet is going on a network to be used by quite a few people, if it breaks for any reason, and I'm still teaching myself VB, I best stick to a less complicated solution, thank you very much for your interest, I will look to use your workings for this in the near future.

Yard, thanks also for your interest, I didn't quite get your original solution, having slept on it, a moment of clarity boomed. I have also put a button on my sheet to run the advanced filter to keep it away from prying fingers!, I will use this as a base to expand my sheet to give the options of date ranges and display all of the info or selections of it.

Gents - once again thanks very much.
 
Upvote 0
Hi Jon, can you explain how to amend you code to run with just one cell (B2) not two
 
Upvote 0
This is a little late but wanted to let YARD know his solution was spot on. If I'm always using 2 criteria. I'm using 5 criteria, the user only wants to pick 1 or 2 at the time but the option should be available. Anyway, if they don't choose all five, code bombs. Any idea on how to avoid empty criteria?
 
Upvote 0

Forum statistics

Threads
1,215,903
Messages
6,127,650
Members
449,394
Latest member
fionalofthouse

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