Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Select region

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select region

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

--
Regards,
Tom Ogilvy


"Simon Woods" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Select region

Thanks Tom

"Tom Ogilvy" wrote in message
...
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

--
Regards,
Tom Ogilvy


"Simon Woods" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste values all cells in a region which refers to out of region Vijay Excel Worksheet Functions 0 August 25th 09 06:03 AM
Select filled region only in non-adjacent columns hmm Excel Discussion (Misc queries) 1 August 19th 07 03:38 PM
[Help]Excel mouse select region bot Excel Programming 0 November 8th 05 04:41 AM
Select current region and print Tempy Excel Programming 2 April 20th 05 05:47 AM
Select current region less one column Soniya[_2_] Excel Programming 1 January 12th 04 02:05 PM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"