I am new to Excel. I am trying to write a macro that (1) does an alphabetical sort for rows 9 through 50 (based on the contents in Column B; (2) Put the rows that have a zero in Column B at the bottom of the sort; and then (3) hide those rows that have a zero in Column B.
Below is my code that does not accomplish this. Can someone point me in the right direction?
Thank you in advance for your help.
--------------
Sub Macro2()
'
' Macro2 Macro
'
'
Range("A9:A50").EntireRow.Hidden = False
On Error Resume Next
Range("A9:A50").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
Rows("9:50").Select
Selection.EntireRow.Hidden = False
ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort.SortFields.Add Key:=Range("B9" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort
.SetRange Range("B9:AH50")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("A9:A50").EntireRow.Hidden = False
On Error Resume Next
Range("b9:b49").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
End With
Range("D3").Select
End Sub
Below is my code that does not accomplish this. Can someone point me in the right direction?
Thank you in advance for your help.
--------------
Sub Macro2()
'
' Macro2 Macro
'
'
Range("A9:A50").EntireRow.Hidden = False
On Error Resume Next
Range("A9:A50").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
Rows("9:50").Select
Selection.EntireRow.Hidden = False
ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort.SortFields.Add Key:=Range("B9" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("2nd Qtr 2012").Sort
.SetRange Range("B9:AH50")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("A9:A50").EntireRow.Hidden = False
On Error Resume Next
Range("b9:b49").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
End With
Range("D3").Select
End Sub