我正在学习excel中VBA编码的基础知识。我试图创建一个VBA代码来选择一个范围内的“n”(给定数量的行)块,然后对从最高到最低的数字中选择的这些行进行排序。请参阅下面的示例。有任何想法吗?。预先感谢。
期望的范围。
选定的块
期望的排序
尝试解决这个问题。
sub meh()
dim i as long, rws as long
rws=4
with worksheets(1)
for i=rws+1 to .cells(.rows.count, "A").end(xlup).row step rws *2
with .cells(i, "A").resize(rws, 1)
.Sort Key1:=.cells(1), Order1:=xldescending, _
Orientation:=xlTopToBottom, Header:=xlNo
end with
next i
end with
end sub