Hello all,

The macro below is excel generated

I would like to modify it so that if I select range E13:E19 and then run the macro, excel understands that I want range E13:Y19 to be selected

It will also automatically change the following line so that 13 and 19 are used:

ActiveWorkbook.Worksheets("INSTALLATION").Sort.SortFields.Add Key:=Range( _
        "G13:G19"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal

For example, if I select E4:E19 and run the macro, it will select E4:Y19 and sort it by G4:G19


Thanks
Lovi




Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+w
'
    Range("E13:Y19").Select
    ActiveWorkbook.Worksheets("INSTALLATION").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("INSTALLATION").Sort.SortFields.Add Key:=Range( _
        "G13:G19"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("INSTALLATION").Sort
        .SetRange Range("E13:Y19")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub