Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 26th, 2012  |  syntax: VisualBasic  |  size: 0.48 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Sub Macro1()
  2. '
  3. ' Macro1 Macro
  4. '
  5.  
  6. '
  7. Range("A2:D20").Select
  8. ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
  9. ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("D2:D20") _
  10.      , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
  11. With ActiveWorkbook.Worksheets("Sheet1").Sort
  12.     .SetRange Range("A1:D20")
  13.     .Header = xlYes
  14.     .MatchCase = False
  15.     .Orientation = xlTopToBottom
  16.     .SortMethod = xlPinYin
  17.     .Apply
  18. End With
  19. End Sub
clone this paste RAW Paste Data