Clear Visible Contents of a Column is Filtered Range have Data

ahuang3433

New Member
Joined
Jan 24, 2017
Messages
39
VBA Code:
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=38, Criteria1:= _
        "Reference PjM Comment for PN"

    ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=6, Criteria1:= _
        "<>TBD*", Operator:=xlAnd

Hi,

Based on the filter criteria that I have here, I'm trying to create a variable where if there is data return based on the filter criteria to delete visible cell data on Column AL excluding the header row. If there is no data return, skip.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi ahuang3433
try adding this line to your code
VBA Code:
Range("AL2:AL" & Range("AL" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).ClearContents
 
Upvote 0
How about
VBA Code:
With ActiveSheet.ListObjects("Table2")
   .Range.AutoFilter Field:=38, Criteria1:="Reference PjM Comment for PN"
   .Range.AutoFilter Field:=6, Criteria1:="<>TBD*", Operator:=xlAnd
   If .ListColumns(38).Range.SpecialCells(xlVisible).Count > 1 Then
      .ListColumns(38).DataBodyRange.ClearContents
   End If
End With
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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