Solved

DataSort absolute values?

Posted on 2016-10-25
5
59 Views
Last Modified: 2016-10-25
How do I remove the absolute value in lines 3 and 6?  The dataset will vary in size.

ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Add Key:=Range( _
        "A2:A32"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Add Key:=Range( _
        "C2:C32"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("MODetails").Sort
        .SetRange Range("A1:L32")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    ActiveWorkbook.Save
    ActiveWorkbook.Close

Open in new window

0
Comment
Question by:RWayneH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 41859051
Perhaps.
Dim LastRow As Long

    LastRow = Sheets("MODetails").Range("A" & Rows.Count).End(xlUp).Row
    ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Add Key:=Range( _
        "A2:A" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    ActiveWorkbook.Worksheets("MODetails").Sort.SortFields.Add Key:=Range( _
        "C2:C" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("MODetails").Sort
        .SetRange Range("A1:L" & LastRow)
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    ActiveWorkbook.Save
    ActiveWorkbook.Close

Open in new window


Note I've also changed line 9 as that's actually for the entire range you want to sort by columns A and C.
0
 

Author Comment

by:RWayneH
ID: 41859112
I am getting a syntax error on line 5 thru 10?  When I copy/paste into Mod?
0
 

Author Closing Comment

by:RWayneH
ID: 41859118
Appreciate the help.
0
 
LVL 34

Expert Comment

by:Norie
ID: 41859123
Did you fix the syntax error?
0
 

Author Comment

by:RWayneH
ID: 41859675
Yes, I copied the line numbers too, vba did not like that.  All good.  Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question