mardi 24 février 2015

How to use control shift down key and sort from low value to high value in excel vba 2010?

Hi I am working with a lot of random column cells. I am trying to use this option in excel vba. I used macro recorder but not working when I use this on another sheet.


Sorting also not working. Any idea??


For more details please check the below code :



Range("I1").Select
ActiveCell.FormulaR1C1 = "=RC[-3]/1000"
Range("I1").Select
Selection.AutoFill Destination:=Range("I1:I5396")
Range("I1:I5396").Select
Range("J1").Select
ActiveCell.FormulaR1C1 = ""
Columns("I:I").Select
Selection.Copy
Columns("J:J").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("J:J").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("347").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("347").Sort.SortFields.Add Key:=Range("J1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("347").Sort
.SetRange Range("J1:J5396")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Aucun commentaire:

Enregistrer un commentaire