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?
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
Code:
    With ActiveSheet.AutoFilter.Range
        .Offset(1).Resize(.Rows.Count - 1).Select
    End With
 

Smitty

MrExcel MVP
Joined
May 15, 2003
Messages
29,536
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,
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
You're welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,750
Messages
5,446,277
Members
405,393
Latest member
sully361

This Week's Hot Topics

Top