Activate not Select, Apply special filter and delete visible cells

Rowland Hamilton

Active Member
Joined
Nov 13, 2009
Messages
250
Folks,

How do I change this code so that it does not have to select the cells, but can activate them instead?
Code:
'Delete Filtered Rows
    Application.CutCopyMode = False
      Range("a2", Selection.SpecialCells(xlCellTypeLastCell)).Select
      Selection.SpecialCells(xlCellTypeVisible).Select
      Selection.EntireRow.Delete

I read activating also slows data processing, but I don't think I have a choice, there.

Thanks, Rowland Hamilton
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Folks,

How do I change this code so that it does not have to select the cells, but can activate them instead?
Code:
'Delete Filtered Rows
    Application.CutCopyMode = False
      Range("a2", Selection.SpecialCells(xlCellTypeLastCell)).Select
      Selection.SpecialCells(xlCellTypeVisible).Select
      Selection.EntireRow.Delete

I read activating also slows data processing, but I don't think I have a choice, there.

Thanks, Rowland Hamilton

Be sure you try this on a copy first, or you might lose your data.
Code:
'Delete Filtered Rows
    Application.CutCopyMode = False
      Range("a2", Selection.SpecialCells(xlCellTypeLastCell)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
 
Upvote 0
If you tried the code as modified and it worked, then the answer is to get rid of the Select and Activate altogether. They are not really needed for the code to work, if the code is constructed properly. But you can, in most cases use Ativate anywhere you see Select. The problem arises when you try to use Selection to reference an Active item that was not selected. That would throw an error. I would suggest that you search around on the web for articles on the subject or check some of the free tutorial sites to get a better understanding of how it works. It is too much to try and explain in this forum.
 
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