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 / January 2006

Tip: Looking for answers? Try searching our database.

Select region

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Woods - 23 Jan 2006 14:30 GMT
Hi

I've not got used to programming excel. I'm trying to select the bottom
right cell and then select the current region in order to do a sort of the
first three columns without headers.

I'm obviously getting it wrong!!!

Here's my code, but instead of getting the bottom right I've been getting A4
as the data range I want to sort will always start there. When I execute
this, just row 1 gets hilighted and then the sort call gets  thrown out.

   m_oSheet.Cells.Range("A4").Select
   m_oSheet.Cells.Range("A4").Activate

   With m_oSheet.Cells.CurrentRegion
       .Select
       .Activate
       .Sort Key1:=Range("C4"), Order1:=xlAscending, _
             Key2:=Range("B4"), Order2:=xlAscending, _
             Key3:=Range("A4"), Order3:=xlAscending, _
             Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
             DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=xlSortNormal
   End With

Thanks

Simon
Tom Ogilvy - 23 Jan 2006 15:22 GMT
 Dim rng as Range, bottomright as Range
 m_oSheet.Range("A4").Select
   With m_oSheet
   set rng = .Range("A4").CurrentRegion
   set bottomright = rng(rng.count)
   set rng = .Range("A4",bottomright)

      rng.Sort Key1:=.Range("C4"), Order1:=xlAscending, _
             Key2:=.Range("B4"), Order2:=xlAscending, _
             Key3:=.Range("A4"), Order3:=xlAscending, _
             Header:=xlGuess, OrderCustom:=1, _
             MatchCase:=False, _
             Orientation:=xlTopToBottom, _
             DataOption1:=xlSortNormal, _
             DataOption2:=xlSortNormal, _
             DataOption3:=xlSortNormal
   End With

Signature

Regards,
Tom Ogilvy

> Hi
>
[quoted text clipped - 26 lines]
>
> Simon
Simon Woods - 23 Jan 2006 15:26 GMT
Thanks Tom

>  Dim rng as Range, bottomright as Range
>  m_oSheet.Range("A4").Select
[quoted text clipped - 46 lines]
>>
>> Simon
 
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.