Dynamic Filter

Shrinivas

New Member
Joined
Aug 17, 2006
Messages
8
I have list in following fashion.

A B C D
Act Serial number Month Units
100412403 8604158 Sep-17 351
100412403 8604158 Aug-17 396
100412403 8604158 Jul-17 379
100412403 8604158 Jun-17 407

I have 25000 rows (or more)(records), I want to filter by column 'A' & compare each record in column 'D'. Can we develop something like arrow button so by hitting it next record in column 'A' will get filtered, instead of selecting number every time ?
Thanks in advance,
shrinivas.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi ,

See if this helps ; the code is as follows :
Code:
Public nextvalue As Boolean


Sub Button1_Click()
    nextvalue = True
End Sub

Public Sub FilterOneByOne()

'          In the References under Tools , select Microsoft Scripting Runtime
'          since the usage of a dictionary is dependent on this
           Dim lastrow As Long, i As Long, counter As Long
           Dim inputdatarange As Range, cell As Range
           Dim cellval As Variant
           Dim dict As New Dictionary
           
           lastrow = Me.Range("A" & Rows.Count).End(xlUp).Row
           Set inputdatarange = Me.Range("A2:A" & lastrow)
           
           If Me.AutoFilterMode Then inputdatarange.AutoFilter
           
           For Each cell In inputdatarange
               If Not (dict.Exists(cell.Value)) Then
                  dict.Add cell.Value, cell.Value
               End If
           Next
                  
           For Each cellval In dict.Keys
               nextvalue = False
               counter = 0
               inputdatarange.Offset(-1).AutoFilter field:=1, Criteria1:=cellval
               Do While Not nextvalue
                  counter = counter + 1
                  DoEvents
                  If counter > 100000# Then nextvalue = True
               Loop
           Next
           
           inputdatarange.AutoFilter
End Sub
There is a time delay between each selection , so that even if you do not press the NEXT button , when the time delay expires , it will automatically move on to the next ID.

The workbook itself can be downloaded from here :

https://www.dropbox.com/s/3l5xwxko3mf2kqg/Sample File.xlsm?dl=0
 
Last edited:
Upvote 0
sorry but this files enables other files but it shows only one value of from month & units head & timer is very fast
 
Upvote 0

Forum statistics

Threads
1,221,527
Messages
6,160,342
Members
451,638
Latest member
MyFlower

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