Reputation: 279
I´m learning the very basics of VBA coding in excel. I am trying to create a VBA code to select blocks of "n" (a given numbers of rows) within a range and then sort these rows chosen from the highest to the lowest number. Please see the example below. Any ideas?. Thank in advance.
Desired range.
Selected blocks
Desired sorting
Upvotes: 0
Views: 87
Reputation:
Try working through this.
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
Upvotes: 1