Hopefully simple question

entrekin

New Member
Joined
Feb 7, 2014
Messages
2
I am writing a macro that I want to use to select all cells in filtered columns A:P except for the header row, which is always row 1. I've tried using

ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Cells(1)).Select

but it selects all the way to A1. What I want is to select from the end to the first visible (based on the filter) cell below A1. I have a feeling the answer is simple, but I can't seem to figure it out. Actually, I thought my code worked the first time I ran it, but every time since then, it has selected all the way to A1. Any ideas?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Code:
    With ActiveSheet.AutoFilter.Range
        .Offset(1).Resize(.Rows.Count - 1).Select
    End With
 
Upvote 0
Here's one way. Just note that it's generally not necessary to select.

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> lr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    lr = Cells(Rows.Count, "A").End(xlUp).Row<br>    <br>    Range("A2:A" & lr).SpecialCells(xlCellTypeVisible).Select<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH,
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,239
Members
448,951
Latest member
jennlynn

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