K
k1ngr
In Excel 2007, I'm trying to sort on column A, with headers of :x: and "y".
There is a formula in column A:
=IF(B2="","",B2), then copied down.
I need to have Rows 2-4 (cells that don't display anything, but have a
formula in them) to sort below the cells which display characters. Does
anyone have a suggestion on how to accomplish this?
I am using a command button to initiate the sort - the VBA code for the
command button is shown below the spreadsheet.
A B
1 y z
2
3
4
5 a a
6 c c
7 m m
8 r r
9 x x
--------------------
Private Sub CommandButton1_Click()
'
Application.Goto Reference:="data"
ActiveWorkbook.Worksheets("data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("data").Sort.SortFields.Add Key:=Range( _
"A2:A20"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("data").Sort
.SetRange Range("A1:B20")
.Header = xltrue
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
There is a formula in column A:
=IF(B2="","",B2), then copied down.
I need to have Rows 2-4 (cells that don't display anything, but have a
formula in them) to sort below the cells which display characters. Does
anyone have a suggestion on how to accomplish this?
I am using a command button to initiate the sort - the VBA code for the
command button is shown below the spreadsheet.
A B
1 y z
2
3
4
5 a a
6 c c
7 m m
8 r r
9 x x
--------------------
Private Sub CommandButton1_Click()
'
Application.Goto Reference:="data"
ActiveWorkbook.Worksheets("data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("data").Sort.SortFields.Add Key:=Range( _
"A2:A20"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("data").Sort
.SetRange Range("A1:B20")
.Header = xltrue
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub