vba - Select Used Range minus the top header

J

Johnny

Hi all,

I am using "ActiveSheet.UsedRange.Select" to select the used range and
that's great. However, I can't figure out how to ignore the first row
of data, because it's a header. I'm still searching the boards but I
haven't seen anyone ask this question.

Thanks
John
 
D

Don Guillett

One way?

Sub SelectUsedRangeLessTopRow()
With ActiveSheet.UsedRange
mr = .Rows.Count
mc = .Columns.Count
.Range(Cells(2, 1), Cells(mar, mc)).Select
End With
End Sub
 
J

Johnny

Sub SelectUsedRangeLessTopRow()
With ActiveSheet.UsedRange
mr = .Rows.Count
mc = .Columns.Count
        .Range(Cells(2, 1), Cells(mar, mc)).Select
End With
End Sub

Don,

Thank you very much for your reply. I'm only fixing/posting the typos
in case anyone else wants to use this:


Sub SelectUsedRangeLessTopRow()
With ActiveSheet.UsedRange
mr = .Rows.Count
mc = .Columns.Count
Range(Cells(2, 1), Cells(mar, mc)).Select
End With

End Sub
 
D

Dave Peterson

A couple more:

With ActiveSheet.UsedRange
.Offset(1, 0).Resize(.Rows.Count - 1).Select
End With

Or if you always wanted to select A2 through the lastusedcell:

With ActiveSheet
.Range("a2", .Cells.SpecialCells(xlCellTypeLastCell)).Select
End With

There's a difference between these two. The .usedrange doesn't have to start in
A1.
 
C

Chip Pearson

Try

With Worksheets(1).UsedRange
.Cells(2, 1).Resize(.Rows.Count - 1, .Columns.Count).Select
End With


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top