1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行Sub 双条件排序首列升序次列降序() With 钽吟篑瑜ActiveWorkbook.ActiveSheet.Sort .SortFields.Clear .SortFields.Add Key:=Application.Intersect(ActiveCell.EntireColumn, ActiveCell.CurrentRegion),SortOn:=xlSortOnValues, Order:= xlAscending '首列按数值升序排序 .SortFields.Add Key:=Application.Intersect(ActiveCell.Offset(0, 1) .EntireColumn, ActiveCell.CurrentRegion),SortOn:=xlSortOnValues,Order:=xlDescending, DataOption:=xlSortNormal '次列以笔画为基准降序排序 .SetRange Application.Intersect(Selection.CurrentRegion, Selection. CurrentRegion.Offset(1, 0)) .SortMethod=xlStroke .Apply End WithEnd Sub
5、选中B5单元格(光标溴腻男替位置很重要,激活不同列有不同结果),用快捷键Alt+F8调出运行宏窗口,然后单击“执行”按钮,B列数据除首行外均按数值升序排列