VBA - hiding rows based on cell A being greater or less than cell B

dlwblue

New Member
Joined
Feb 7, 2006
Messages
7
I have a sheet and in a cell you enter a certain date, let’s say cell A (yes I know there would usually be a number too!) I want rows to hide or be visible based on how that date relates to another date in a cell on another tab, let’s say cell B.

Both are open cells and anything, within reason, can be entered.

if A is greater than B then rows 33 and 34 need to be visible, if A is greater than (B+14) then rows 33 to 36 need to be visible, if A is less than (B-30) then rows 31 and 32 need to be visible and for everything else (which is if A is blank or less than B but nor more than 30 less) rows 31 to 36 are hidden.

im not precious about having cell B from the other tab duplicated in one of the columns on the same sheet as A, or naming cells, and have tried putting the result of B, B-30 and B+14 in 3 cells on the same tab as cell A, but I can’t figure the code to say if A is greater or less than these 3 cells.

I have probably hundreds, certainly dozens, of if case equals x then true or false hide rows. and they are all working great, it’s just the greater or less than part that I’m struggling with.

any Help would be massively appreciated, I’ve been working on this project for ages and am finally close to finishing and this last bit has me completely stumped.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,223,970
Messages
6,175,721
Members
452,667
Latest member
vanessavalentino83

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