Filter Problem - show column difference

N

northwestihi

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.
 
J

JW

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
 
N

northwestihi

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










- Show quoted text -

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

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top