VBA Filter based on cell "I1" value

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,371
Office Version
  1. 2010
Hello,</SPAN></SPAN>

I want VBA, which can filter, based on cell "I1" value and bring along with one prior row before it.</SPAN></SPAN>

Example...all data</SPAN></SPAN>


Book1
ABCDEFGHI
111
2
3
4
5n1n2n3n4n5n6Sum
60111216
70032005
801432111
922504215
1030605317
11214121222
12315243330
13416304431
14517405536
1560517625
1682620725
1790741829
18111853028
1906140011
2007262017
2128083021
2200290112
231040139
240201249
251302309
2624034114
2745045220
2813137116
2925250216
3030061414
3140072619
3251103717
3302304817
3413405013
3524516018
3603342315
3720053010
3802160110
3910071211
4000182011
4150019318
42601210423
43010411622
44130512728
45200713022
4602180011
4713291117
48240102220
49301113321
50402124426
51503135026
52015140020
53000151016
54011162020
55132173026
Sheet2


Result...data after the filter </SPAN></SPAN>


Book1
ABCDEFGHI
111
2
3
4
5n1n2n3n4n5n6Sum
70032005
801432111
18111853028
1906140011
3802160110
3910071211
4000182011
45200713022
4602180011
Sheet2-AfterFilter


Thanks In Advance </SPAN></SPAN>
Using version 2000</SPAN></SPAN>

Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
Code:
Sub Motilulla()
   Dim Cl As Range
   
   For Each Cl In Range("I6", Range("I" & Rows.Count).End(xlUp))
      If Cl.Value <> Range("I1") And Cl.Offset(1) <> Range("I1") Then
         Cl.EntireRow.Hidden = True
      End If
   Next Cl
End Sub
 
Upvote 0
How about
Code:
Sub Motilulla()
   Dim Cl As Range
   
   For Each Cl In Range("I6", Range("I" & Rows.Count).End(xlUp))
      If Cl.Value <> Range("I1") And Cl.Offset(1) <> Range("I1") Then
         Cl.EntireRow.Hidden = True
      End If
   Next Cl
End Sub
Wow! Fluff, it worked as appeal</SPAN></SPAN>

Thank you for your kind help</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti
:)</SPAN></SPAN>
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,634
Members
449,460
Latest member
jgharbawi

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