如何把下面代码改写成正序和倒序循环,点击一下正序排列,再点击一下变成倒序排列
Sub 前20红色()For i = 1 To 10
y = Application.WorksheetFunction.Match(i, Columns("C"), False)
shthz.Range("C" & y).Font.Color = vbRed
Next
End Sub
Sub 排序()
'
' 宏2 宏
'
Dim shthz As Worksheet
Set shthz = Worksheets("汇总")
Dim i As Integer, j As Integer, row As Integer
Dim col As Integer, colstr As String
col = shthz.Cells(1, 256).End(xlToLeft).Column
colstr = getChar(col)
If col > 82 Then
MsgBox "统计的天数超过了80天,请删除最右边的数据,再运行程序!"
Exit Sub
End If
row = shthz.Range("A65536").End(xlUp).row
ActiveWorkbook.Worksheets("汇总").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("汇总").Sort.SortFields.Add Key:=Range("C2:C2860"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("汇总").Sort
.SetRange Range("A1:" & colstr & row)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=-6
End Sub