Consulting

Results 1 to 4 of 4

Thread: Custom sort modification

  1. #1

    Custom sort modification

    I recoded this macro to help sort specific titles in a explicit order. I would like to change it so that the range is dynamic. the length will not always be the same.
    Can anyone help?


    [VBA]
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add Key:=Range("C3:C140") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
    "Medicare Subtotal, Other Medicare HMO Subtotal,Senior Blue Subtotal,Medical Assistance Subtotal,Amerihealth Mercy Subtotal,CCBH Subtotal,Gateway Subtotal,MedPlus Three Rivers Subtotal,Aetna Subtotal,Amerihealth Admin Subtotal,Auto Subtotal,BHP Subtotal,BHP Employee Subtotal,Blue Shield Subtotal,Capital Blue Cross Subtotal,Cigna Subtotal,Health America Subtotal,Independence BC Subtotal,Keystone Central Subtotal,Keystone East Subtotal,Self-Pay Subtotal,United Healthcare Subtotal,Workers Comp Subtotal,Senior Blue" _
    , DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet2").Sort
    .SetRange Range("A3:O140")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    [/VBA]

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  3. #3

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Preseb, please do not post duplictes when you clearly had an answer there, an administrator had also asked you to surround your code with the VBA tags (as i have done for you in your first post of this thread), please remember next time.

    Thread Closed
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •