Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

vba - Select Used Range minus the top header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johnny - 21 May 2008 14:19 GMT
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
Don Guillett - 21 May 2008 14:30 GMT
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

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

> Hi all,
>
[quoted text clipped - 5 lines]
> Thanks
> John
Johnny - 21 May 2008 14:51 GMT
> Sub SelectUsedRangeLessTopRow()
> With ActiveSheet.UsedRange
[quoted text clipped - 3 lines]
> 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
Dave Peterson - 21 May 2008 15:10 GMT
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.

> Hi all,
>
[quoted text clipped - 5 lines]
> Thanks
> John

Signature

Dave Peterson

Chip Pearson - 21 May 2008 19:19 GMT
Try

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

Signature

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

> Hi all,
>
[quoted text clipped - 5 lines]
> Thanks
> John
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.