PC Review


Reply
Thread Tools Rate Thread

Cursor Position After Sort Operation

 
 
Jeff W.
Guest
Posts: n/a
 
      28th Jan 2008
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 With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      28th Jan 2008
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.
>
>
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      28th Jan 2008

'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 With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      28th Jan 2008
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.
> >
> >
> >

 
Reply With Quote
 
Jeff W.
Guest
Posts: n/a
 
      28th Jan 2008
Excellent!

Thank you Jim...

<Jeff>


"Jim Cone" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> '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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not complete cursor operation because the table schema changed after the cursor was declared Ajit Microsoft VB .NET 2 4th Oct 2004 05:38 PM
Could not complete cursor operation because the table schema changed after the cursor was declared Ajit Microsoft Dot NET 2 4th Oct 2004 05:38 PM
Set cursor position Kimmy Microsoft Access Forms 1 10th Sep 2004 06:54 PM
cursor position NTL Microsoft Excel Programming 1 18th Jan 2004 08:23 PM
How can I set the cursor position in VB.NET Christian Blackburn Microsoft VB .NET 3 19th Sep 2003 01:52 PM


Features
 

Advertising
 

Newsgroups
 


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