ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter Problem - show column difference (https://www.excelbanter.com/excel-programming/391232-filter-problem-show-column-difference.html)

[email protected]

Filter Problem - show column difference
 
Hi, I wonder if anyone could help with this, preferably
programmatically. I am a newbie to Filters so step by step would be
nice....

I have two columns (J and K), in which the same row may show the same
or different (text) value, depending on complex calcs elsewhere in the
sheet. J and K already have a manual autofilter set up. The rows run
from J2 to K633, with the first row showing the category name.

What I want is, a programmed filter which shows only those rows where
the column J and K values are different....

Preferably in code, so I can attach it to a button, or so I could get
it run run automatically when calculations change.....

Sounds simple enough, but hours of searching the web have drawn a
blank...

Thanks.


JW[_2_]

Filter Problem - show column difference
 
How about just hiding the rows where J and K don't match? Would that
work?
Untested.
sub tester()
Dim cl as Range
Dim rng as Range
Set rng=range("J2:J633")
For Each cl In rng
If cl.Value=cl.Offset(0,1).Value Then cl.EntireRow.Hidden+True
Next cl
Set rng=Nothing
End Sub

If course, it would be best to set the range programatically just in
case it chages. You would also probably want to set all rows to
hidden=false before hiding any rows.

HTH


wrote:
Hi, I wonder if anyone could help with this, preferably
programmatically. I am a newbie to Filters so step by step would be
nice....

I have two columns (J and K), in which the same row may show the same
or different (text) value, depending on complex calcs elsewhere in the
sheet. J and K already have a manual autofilter set up. The rows run
from J2 to K633, with the first row showing the category name.

What I want is, a programmed filter which shows only those rows where
the column J and K values are different....

Preferably in code, so I can attach it to a button, or so I could get
it run run automatically when calculations change.....

Sounds simple enough, but hours of searching the web have drawn a
blank...

Thanks.



[email protected]

Filter Problem - show column difference
 
On 13 Jun, 17:49, JW wrote:
How about just hiding the rows where J and K don't match? Would that
work?
Untested.
sub tester()
Dim cl as Range
Dim rng as Range
Set rng=range("J2:J633")
For Each cl In rng
If cl.Value=cl.Offset(0,1).Value Then cl.EntireRow.Hidden+True
Next cl
Set rng=Nothing
End Sub

If course, it would be best to set the range programatically just in
case it chages. You would also probably want to set all rows to
hidden=false before hiding any rows.

HTH



wrote:
Hi, I wonder if anyone could help with this, preferably
programmatically. I am a newbie to Filters so step by step would be
nice....


I have two columns (J and K), in which the same row may show the same
or different (text) value, depending on complex calcs elsewhere in the
sheet. J and K already have a manual autofilter set up. The rows run
from J2 to K633, with the first row showing the category name.


What I want is, a programmedfilterwhich shows only those rows where
thecolumnJ and K values are different....


Preferably in code, so I can attach it to a button, or so I could get
it run run automatically when calculations change.....


Sounds simple enough, but hours of searching the web have drawn a
blank...


Thanks.- Hide quoted text -


- Show quoted text -


Thanks. That works a treat!
But it's a bit slooow. Any ideas on speeding it up?

Cheers



All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com