VBA Autofilter - delete visible cells issue

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

I want to delete Visible cells after autofilter.it is deleting all rows(hidden Rows as well.)
Whats wrong with below code,

With wsInput.Range("A1").CurrentRegion
.AutoFilter FIELD:=cls_mod.Col_Month, Criteria1:="<>" & month
If .Columns(1).SpecialCells(xlCellTypeVisible).Count > 1 Then
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
wsInput.Cells.AutoFilter
Else
wsInput.Cells.AutoFilter
End If
End With


Thanks
mg
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
How about
VBA Code:
With wsInput
   .Range("A1").CurrentRegion.AutoFilter FIELD:=cls_mod.Col_Month, Criteria1:="<>" & Month
   .AutoFilter.Range.Offset(1).EntireRow.Delete
   .AutoFilterMode = False
End With
 
Upvote 0
Hi Fluff,

Thanks for your help, your code is working, Issue was with my OS.
Reinstalled now both are working perfectly.


Regards,
mg
 
Upvote 0
Glad it's sorted & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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