Replace Selections with Activations in SpecialCells formulas filtering visible cells

Rowland Hamilton

Active Member
Joined
Nov 13, 2009
Messages
250
Folks,

How do I replace all selections with activations in this code:

Code:
'Delete Filtered Rows (how to remove selection?)
      Range("a2", Selection.SpecialCells(xlCellTypeLastCell)).Select
      Selection.SpecialCells(xlCellTypeVisible).Select
      Selection.EntireRow.Delete

I tried skipping the first line and altering the 2nd line this way, but it didn't work:
Code:
      rngTable.SpecialCells(xlTypeVisible).Activate


relys on this:
Code:
Sub Remove_Dupes() '(wsR As Worksheet) 'passthrough
Dim wsR As Worksheet 'Results worksheet - not needed with passthrough
Dim lngFRow As Long 'First row
Dim lngLRow As Long 'Last row
Dim lngLCol As Long 'Last column

Dim rngTable As Range 'Table data
Set wsR = Worksheets("Results") 'not needed with passthrough
'Find last row
 lngFRow = wsR.Range("A1").End(xlDown).Row
 lngLRow = wsR.Range("A" & Rows.Count).End(xlUp).Row
 lngLCol = wsR.UsedRange.Columns.Count
'Remove any existing filter
    wsR.Activate
    wsR.AutoFilterMode = False
        
 'Set approximate table range
 Set rngTable = wsR.Range(wsR.Cells(lngFRow - 1, 1), wsR.Cells(lngLRow, lngLCol))

'Apply new filter
   rngTable.Activate
   rngTable.AutoFilter

'Filter for blanks
    rngTable.AutoFilter Field:=1, Criteria1:="=", _
            Operator:=xlOr, Criteria2:="=*PLACE_HOLDER*"


'Delete Filtered Rows (how to remove selection?)
    'ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Activate
    Application.CutCopyMode = False
      'Range("a2", Selection.SpecialCells(xlCellTypeLastCell)).Select
      'Selection.SpecialCells(xlCellTypeVisible).Select
      
      
      rngTable.SpecialCells(xlTypeVisible).Activate
Stop
      'Selection.EntireRow.Delete
 
ActiveSheet.AutoFilterMode = False
End Sub
THank you,
Rowland Hamilton
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
.
.

Why the need to select or activate anything?

Range("A2").CurrentRegion.SpecialCells(xlCellTypeVisible).EntireRow.Delete
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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