My data in the way it is entered
在我的数据中,我想按照“收入的性质”列的升序对银行1的数据进行排序,对银行2的数据按照“收入的性质”列的升序排序,对于所有银行依此类推。但是银行名称在银行的起始行中只写了一次。可以有许多银行和许多数据在每个银行,所以如果我得到一个VBA代码排序数据与一次点击它将是非常有帮助的。谢谢
发布于 2019-04-11 14:12:29
代码注释解释流程。
Option Explicit
Sub sortAreas()
Dim a As Long
'define the worksheet
With Worksheets("sheet1")
'used range in column D
With .Range(.Cells(4, "D"), .Cells(Rows.Count, "D").End(xlUp))
'all dates in column D
With .SpecialCells(xlCellTypeConstants, xlNumbers)
'loop through Areas of discontiguous range
For a = 1 To .Areas.Count
'identify Area and expand to 4 columns wide
With .Areas(a).Resize(, 4)
'sort on the third column in ascending order
.Sort key1:=.Cells(1, 3), order1:=xlAscending, Header:=xlNo
End With
Next a
End With
End With
End With
End Subhttps://stackoverflow.com/questions/55625438
复制相似问题