Filter and Count Formula

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help with the following code for filtering Data and with Formulas for Counting Data?

I have Headers in Columns "A2:J2" and Data in "A3:J" Sheet1

I have the following macro that deletes all visible rows when filtering the data in columns "D:J" but I don't want to delete the 'Entire Rows' I only want to delete Data in columns "A3:J" and use 'delete ShiftUp' if possible?

Code:
[FONT=Verdana]Sub Filter()

[/FONT]
[FONT=Verdana]Dim Data As Worksheet: Set Data = Sheet1
    
    Application.ScreenUpdating = False
    
        With Data
            .Range(.Range("A3:J3"), .Range("A3:J3").End(xlDown)).Delete Shift:=xlUp
            .AutoFilterMode = False
        End With
    
End Sub
[/FONT]

Also, I have the following Formula that Counts Data from column "D"
Does anyone know how I can use this formula to count only the visible Data when filtering columns "D:J"

Formula '[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=IF(COUNTIF(D:J,$L3)=0,"",COUNTIF(D:J,$L3))'[/FONT]


Regards

pwill
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If the data is filtered you can not only delete a part and scroll the data up, you would have to remove the filter, read record by record and if it meets the filter criteria then delete that data and scroll up.

To count if the data is filtered:

=SUMPRODUCT(SUBTOTAL(2,OFFSET($D$3:$J$3,ROW($D$3:$J$100)-3,))*($D$3:$J$100=$L3))

If you need help with the macro or with the formula, You could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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