Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Cursor Position After Sort Operation

I have a work log I am using in Excel, and have a custom feature that
will sort by status which it gets from the first column.

The cursor postion end up at A1 "top of the page"


Below, is what I have right now and I think the "Range("A1").Select"
should be changed but I dont how to make it position on the first cell
of the last item in the column that has contents

' sort by status
Sheets("Activity").Select
Range("A1:H65536").Select
Selection.sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub


Can someone help me change it to do this, please?

Thanks,

Jeff W.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Cursor Position After Sort Operation

So you want the cursor to end up in the first blank cell in column A??? If so
then...

Sheets("Activity").Range("A1:H65536").Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select

Note that I changed the Header option in your sort from xlGuess to xlYes.
You are better off to specify if you have a header than to let XL make it's
best guess.
--
HTH...

Jim Thomlinson


"Jeff W." wrote:

I have a work log I am using in Excel, and have a custom feature that
will sort by status which it gets from the first column.

The cursor postion end up at A1 "top of the page"


Below, is what I have right now and I think the "Range("A1").Select"
should be changed but I dont how to make it position on the first cell
of the last item in the column that has contents

' sort by status
Sheets("Activity").Select
Range("A1:H65536").Select
Selection.sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub


Can someone help me change it to do this, please?

Thanks,

Jeff W.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Cursor Position After Sort Operation


'sort by status
Sheets("Activity").Select
Range("A1:H65536").Sort Key1:=Range("A2"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
'Range("A1").Select
Cells(Rows.Count, 1).End(xlUp).Select
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - Free trial download for "Special Sort")



"Jeff W."
wrote in message
I have a work log I am using in Excel, and have a custom feature that
will sort by status which it gets from the first column.
The cursor postion end up at A1 "top of the page"

Below, is what I have right now and I think the "Range("A1").Select"
should be changed but I dont how to make it position on the first cell
of the last item in the column that has contents

' sort by status
Sheets("Activity").Select
Range("A1:H65536").Select
Selection.sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub

Can someone help me change it to do this, please?
Thanks,
Jeff W.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Cursor Position After Sort Operation

Oops... My code does not select the sheet you specify so the sort will work
but it may not work out correctly in terms of selecting the correct cell on
the correct sheet. Try this...

Sheets("Activity").Range("A1:H65536").Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Sheets("Activity").Select
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

So you want the cursor to end up in the first blank cell in column A??? If so
then...

Sheets("Activity").Range("A1:H65536").Sort Key1:=Range("A2"), _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select

Note that I changed the Header option in your sort from xlGuess to xlYes.
You are better off to specify if you have a header than to let XL make it's
best guess.
--
HTH...

Jim Thomlinson


"Jeff W." wrote:

I have a work log I am using in Excel, and have a custom feature that
will sort by status which it gets from the first column.

The cursor postion end up at A1 "top of the page"


Below, is what I have right now and I think the "Range("A1").Select"
should be changed but I dont how to make it position on the first cell
of the last item in the column that has contents

' sort by status
Sheets("Activity").Select
Range("A1:H65536").Select
Selection.sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub


Can someone help me change it to do this, please?

Thanks,

Jeff W.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Cursor Position After Sort Operation

Excellent!

Thank you Jim...

<Jeff


"Jim Cone" wrote in message
...

'sort by status
Sheets("Activity").Select
Range("A1:H65536").Sort Key1:=Range("A2"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
'Range("A1").Select
Cells(Rows.Count, 1).End(xlUp).Select
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - Free trial download for "Special Sort")



"Jeff W."
wrote in message
I have a work log I am using in Excel, and have a custom feature that
will sort by status which it gets from the first column.
The cursor postion end up at A1 "top of the page"

Below, is what I have right now and I think the "Range("A1").Select"
should be changed but I dont how to make it position on the first cell
of the last item in the column that has contents

' sort by status
Sheets("Activity").Select
Range("A1:H65536").Select
Selection.sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub

Can someone help me change it to do this, please?
Thanks,
Jeff W.




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
Cursor position saziz Excel Discussion (Misc queries) 2 August 9th 05 08:19 PM
Cursor position? Marc Excel Discussion (Misc queries) 1 March 27th 05 07:09 PM
Cursor Position in VBE ehntd[_5_] Excel Programming 0 November 3rd 04 08:44 AM
cursor position Fan Fan Excel Programming 3 August 14th 04 01:12 AM
Position Cursor to A1 Dennis Damsgaard Excel Programming 3 June 8th 04 10:30 PM


All times are GMT +1. The time now is 06:30 AM.

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"