Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Select same cell after sorting

I would like to adjust this code to do the following:

Say that a cell in row 25 is selected and then the code is run,
the sort takes place perfectly but the activecell remains in row 25.
Is it possible to have the activecell move with the sorted rows,
thus retaining the original selection?

Sub RectifyError()

Sheets("View Rounds").Unprotect Password:="pinev85"

Dim LRow As Long

LRow = Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

If Intersect(ActiveCell, Range("B3:F2" & LRow)) Is Nothing Then
MsgBox "You must select within the round you would like to correct",
vbCritical
GoTo EarlyClose
End If

Rows("3:" & LRow).Sort Key1:=Cells(3, 4), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

'*******
'Select the cell with the data that was originally selected
'*******


EarlyClose:

Sheets("View Rounds").Protect Password:="pinev85"


End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Select same cell after sorting

Put an X into a auxilary column IV in the selected row. then look for the X
to reselect the cell at the end

Sub RectifyError()

Sheets("View Rounds").Unprotect Password:="pinev85"

Dim LRow As Long
Columns("IV").clearcontents
SelectColumn =selection.Column
Range("IV",Selection.Row) = "X"

LRow = Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

If Intersect(ActiveCell, Range("B3:F2" & LRow)) Is Nothing Then
MsgBox "You must select within the round you would like to correct",
vbCritical
GoTo EarlyClose
End If

Rows("3:" & LRow).Sort Key1:=Cells(3, 4), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

'*******
'Select the cell with the data that was originally selected
set c = Columns("IV").find(what:="X",lookin:=xlvalues)
Cells(c.row,SelectColumn).Select
Columns("IV").clearcontents

'*******


EarlyClose:

Sheets("View Rounds").Protect Password:="pinev85"


End Sub


"Sandy" wrote:

I would like to adjust this code to do the following:

Say that a cell in row 25 is selected and then the code is run,
the sort takes place perfectly but the activecell remains in row 25.
Is it possible to have the activecell move with the sorted rows,
thus retaining the original selection?

Sub RectifyError()

Sheets("View Rounds").Unprotect Password:="pinev85"

Dim LRow As Long

LRow = Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

If Intersect(ActiveCell, Range("B3:F2" & LRow)) Is Nothing Then
MsgBox "You must select within the round you would like to correct",
vbCritical
GoTo EarlyClose
End If

Rows("3:" & LRow).Sort Key1:=Cells(3, 4), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

'*******
'Select the cell with the data that was originally selected
'*******


EarlyClose:

Sheets("View Rounds").Protect Password:="pinev85"


End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Select same cell after sorting

Sub RectifyError()

Sheets("View Rounds").Unprotect Password:="pinev85"
'==========
mycell = ActiveCell
'==========

Dim LRow As Long


LRow = Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

If Intersect(ActiveCell, Range("B3:F2" & LRow)) Is Nothing Then
MsgBox "You must select within the round you would like to correct",
vbCritical
GoTo EarlyClose
End If

Rows("3:" & LRow).Sort Key1:=Cells(3, 4), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

'*******
'adjust to your column or use cells.find
Columns(1).Find(mycell).Activate
'Select the cell with the data that was originally selected
'*******


EarlyClose:

Sheets("View Rounds").Protect Password:="pinev85"


End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Sandy" wrote in message
...
I would like to adjust this code to do the following:

Say that a cell in row 25 is selected and then the code is run,
the sort takes place perfectly but the activecell remains in row 25.
Is it possible to have the activecell move with the sorted rows,
thus retaining the original selection?

Sub RectifyError()

Sheets("View Rounds").Unprotect Password:="pinev85"

Dim LRow As Long

LRow = Cells(Rows.Count, 2).End(xlUp).Offset(0, 0).Row

If Intersect(ActiveCell, Range("B3:F2" & LRow)) Is Nothing Then
MsgBox "You must select within the round you would like to
correct", vbCritical
GoTo EarlyClose
End If

Rows("3:" & LRow).Sort Key1:=Cells(3, 4), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

'*******
'Select the cell with the data that was originally selected
'*******


EarlyClose:

Sheets("View Rounds").Protect Password:="pinev85"


End Sub



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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Select all columns with data for sorting. jen907 Excel Discussion (Misc queries) 2 June 29th 09 08:06 PM
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON CAPTGNVR Excel Programming 2 July 8th 07 04:18 PM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
Select Case for Sorting / Grouping Columns Bettergains Excel Programming 2 February 25th 05 08:35 PM


All times are GMT +1. The time now is 04:52 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"