Link to home
Start Free TrialLog in
Avatar of Anne Troy
Anne TroyFlag for United States of America

asked on

Convert Recorded Macro Selections to Current Selection Excel 2007

Here's a recorded macro. I'm having no luck changing the selection(s) to "active selection". I think the search terms required to get an answer are simply too generic.

Bottom line: I want to sort the active selection without being prompted to extend it. Sort A-->Z. I will run the macro from a shape on the worksheet, so I just need a standard sub. Thanks soooo much!!

Sub Macro3()
'
' Macro3 Macro
'

'
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("G5"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("G5:G11")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
photo finish.
Avatar of Anne Troy

ASKER

LOL. I'll check it out tomorrow guys! Thanks so much. :D
Beauteous! Thanks!