View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
[email protected] lhkittle@comcast.net is offline
external usenet poster
 
Posts: 168
Default Sort Marco won't work in 2010

On Friday, August 31, 2012 8:01:35 AM UTC-7, GSENSEI wrote:
My office has just converted us to excel 2010. My lovley spreadsheet

macro that made me the envy of the office no longer works and everyone

now wants my blood.



The sheet is protected.



I have a macro that will select a variable amount of rows and sort

alphabetically. It looks for the hidden cell xdummy then selects every

row above it up to row 13, then sorts A -Z. Except now it doesn't.

Help!



Sub Sort()

'

' Sort Macro

'



'Sheets("Cashflow").Unprotect "Cashflow2012"



Cells.Find(What:="xdummy", After:=ActiveCell, LookIn:=xlFormulas,

LookAt _

:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _

False, SearchFormat:=False).Activate





Rows("13:" & ActiveCell.Row - 1).Select

Selection.Sort Key1:=Range("a13"), Order1:=xlAscending, Header:=xlGuess,

_

OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _

DataOption1:=xlSortNormal



Sheets("Cashflow").Protect "Cashflow2012"



End Sub









--

GSENSEI


Give this a try, from excel 2010.

Option Explicit
Option Compare Text
Sub ASort()

'Sheets("Cashflow").Unprotect "Cashflow2012"
Dim i As Integer
Dim j As Integer
Dim k As Integer

Cells.Find(What:="xdummy", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

i = ActiveCell.Row
j = 13
k = i - j

ActiveCell.Offset(-(i - j - 1), 0).Resize(k - 1, 1).Select
Selection.Sort Key1:=Range("a13"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

'Sheets("Cashflow").Protect "Cashflow2012"

End Sub

HTH
Regards,
Howard