VBA Code to sort an Excel Column in Ascending Order and Expand Selection? -
i attempting sort column d in ascending order in excel file vba. expand selection values in column a-f.
i've used formula starting point:
sort ascending/descending vba excel
it sorts 1 column , in descending order. having trouble finding more examples.
lastrow = .cells(.rows.count, "d").end(xlup).row if (.range("d2").value > .range("d" & cstr(lastrow))) xlsort = xlascending end if .range("d2:d" & lastrow).sort key1:=.range("d2"), order1:=xlsort, header:=xlno, _ ordercustom:=1, matchcase:=false, orientation:=xltoptobottom, _ dataoption1:=xlsortnormal
here answer:
.range("d1") = "index" .columns("a:f").sort key1:=range("d2"), _ order1:=xlascending, header:=xlyes
thanks simoco's comment!
Comments
Post a Comment