Consulting

Results 1 to 4 of 4

Thread: Solved: Sort Defined Range

  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    34
    Location

    Solved: Sort Defined Range

    Why will this code not work, error says the object doesn't support this method.
    Define the range:
    [VBA]Set Data = Range(.Cells(DataStart - 1, i), .Cells(Rows.Count, i).End(xlUp))[/VBA]

    Now sort the range:
    [VBA]Sheets("AutoList").Data.Sort (Sheets("AutoList").Data.Cells(2, 1))[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe this would work

    [vba]

    Set Data = .Range(.Cells(DataStart - 1, i), .Cells(.Rows.Count, i).End(xlUp))
    [/vba]

    but without seeing the context, all the code/workbook, it is hard to be sure.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2007
    Posts
    34
    Location
    "Sort method of Range class failed"

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    [VBA]
    Set Data = Range(.Cells(DataStart - 1, i), .Cells(Rows.Count, i).End(xlUp))
    Data.Sort Data(2)

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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