J
Joyce
I have a worksheet that needs to be able to sort data 3
different ways:
I have created 3 different macros to perform these and
they work fine. However, a problem occurs when I want to
add more rows because the macro refers to a specific range
at the beginning.
Range("A5:I48").Select
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending,
Key2:=Range("C3") _
, Order2:=xlAscending, Key3:=Range("D3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
Sub Macro2()
'
' Macro2 Macro
' Sorts by Project Name/Price Date/Contract Type
'
' Keyboard Shortcut: Ctrl+n
'
Range("A5:I48").Select
Selection.Sort Key1:=Range("C3"), Order1:=xlAscending,
Key2:=Range("A3") _
, Order2:=xlAscending, Key3:=Range("D3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
Sub Macro3()
'
' Macro3 Macro
' Sorts by Contract Type/Price Date/Project Name
'
' Keyboard Shortcut: Ctrl+c
'
Range("A5:I48").Select
Selection.Sort Key1:=Range("D3"), Order1:=xlAscending,
Key2:=Range("A3") _
, Order2:=xlAscending, Key3:=Range("C3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
different ways:
I have created 3 different macros to perform these and
they work fine. However, a problem occurs when I want to
add more rows because the macro refers to a specific range
at the beginning.
Range("A5:I48").Select
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending,
Key2:=Range("C3") _
, Order2:=xlAscending, Key3:=Range("D3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
Sub Macro2()
'
' Macro2 Macro
' Sorts by Project Name/Price Date/Contract Type
'
' Keyboard Shortcut: Ctrl+n
'
Range("A5:I48").Select
Selection.Sort Key1:=Range("C3"), Order1:=xlAscending,
Key2:=Range("A3") _
, Order2:=xlAscending, Key3:=Range("D3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
Sub Macro3()
'
' Macro3 Macro
' Sorts by Contract Type/Price Date/Project Name
'
' Keyboard Shortcut: Ctrl+c
'
Range("A5:I48").Select
Selection.Sort Key1:=Range("D3"), Order1:=xlAscending,
Key2:=Range("A3") _
, Order2:=xlAscending, Key3:=Range("C3"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub