Results 1 to 5 of 5

Sort Macro Run-time error '1004': Application/Object-defined error.

Threaded View

  1. #1
    Registered User
    Join Date
    06-20-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    10

    Sort Macro Run-time error '1004': Application/Object-defined error.

    Hi,

    I am trying to create a piece of VBA code which sorts some data. However on the one sheet there are multiple sets of data to be sorted in alphabetical order. Data may also be added and removed so I am trying to use variables to set the sort range. Here is the code which I am using:

    Range("A3").Select
      
        cellOne = ActiveCell.Address
        
        ActiveCell.Offset(0, 21).Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(-3, 0).Select
        
        cellTwo = ActiveCell.Address
        
        Range(cellOne, cellTwo).Select
        ActiveSheet.Sort.SortFields.Clear
        ActiveSheet.Sort.SortFields.Add Key:=ActiveSheet.Range(cellOne & ":" & cellTwo), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
        With ActiveSheet.Sort
            .SetRange Range(cellOne & ":" & cellTwo)
            .Header = xlNo
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    The error "Run-time error '1004': Application-defined or object-defined error." appears on the .Apply line.

    If anyone could point me in the right direction it would be appreciated.
    Last edited by sam1212; 08-22-2014 at 10:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  2. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  3. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  4. [SOLVED] Macro causes Run time error 1004 Application defined or object-defined error
    By Firefighter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2012, 04:09 AM
  5. Macro - Run-time Error '1004': Application defined or object defined error
    By robby10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2010, 07:55 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1