+ Reply to Thread
Results 1 to 5 of 5

Compile Error. Trying to auto sort

Hybrid View

Gase Compile Error. Trying to auto... 07-01-2010, 12:16 PM
foxguy Re: Compile Error. Trying to... 07-02-2010, 02:19 PM
Gase Re: Compile Error. Trying to... 07-06-2010, 10:48 AM
romperstomper Re: Compile Error. Trying to... 07-06-2010, 10:54 AM
foxguy Re: Compile Error. Trying to... 07-06-2010, 11:33 AM
  1. #1
    Registered User
    Join Date
    06-30-2010
    Location
    london, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Compile Error. Trying to auto sort

    Hi,
    I'm very new to this spreadsheet creation and having some trouble.

    I've created a spreadsheet (A3-K100) and when I double click on an empty cell I get a pop up form (frmTreatTrack) to assist in completing the spreadsheet. This works fine

    I then wanted to auto sort the spreadsheet when new data is entered. So I recorded a marco which sorts the spreadsheet depending on the value in Column J. When I run this macro it works.

    So next I thought I would be able to use the code for this macro and copy & paste in to Sheet1 (location of spreadsheet)

    Now when I double click I get a Complie Error
    "member already exists in an object module from which this object module derives.


    Question is what am i doing wrong and how do I solve it. I've added the code below if this helps or is it the way I'm trying to do it?

    any help would be appreciated.

    (I also have another question which relates to the form I've created. Is it possible to have a pop up Calendar on the date selection if I don't have Calendar Control? - This might need a seperate post but thought I would just ask as I'm here)


    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target = "" Then frmTreatTrack.Show
    End Sub
    
    
    
    Sub Sort()
    '
    ' Sort Macro
    '
    
    '
        Range("A3:K100").Select
        Range("K3").Activate
        ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("J4:J100") _
            , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Sheet1").Sort
            .SetRange Range("A3:K100")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub
    Last edited by Gase; 07-15-2010 at 12:45 PM.

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Compile Error. Trying to auto sort

    Now when I double click I get a Complie Error
    "member already exists in an object module from which this object module derives.
    I don't think this error has anything to do with the Sort. I'm pretty sure that it is in your form somewhere. It would probably be a lot easier for someone to find the problem if you post the workbook (take out any sensitive data first).

    (I also have another question which relates to the form I've created. Is it possible to have a pop up Calendar on the date selection if I don't have Calendar Control? - This might need a seperate post but thought I would just ask as I'm here)
    Yes, start a new thread. If your 2nd question has nothing to do with the first, anyone browsing thread titles won't know it's there, so they won't look in the thread. The whole idea of this forum is to help people, and you don't want to hide a question that someone else might be interested in.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  3. #3
    Registered User
    Join Date
    06-30-2010
    Location
    london, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Compile Error. Trying to auto sort

    Ok,
    I've decided to add a button on my spreadsheet to sort the data..
    Which seems to work ok. and the double click produces the pop up form... So thanks for the help! This will probable work better for me as if I want to rearange data the sort wont kick in.

    Forgive me for asking but could someone let me know how I close a thread and rate it?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Compile Error. Trying to auto sort

    Change the name of your Sub from Sort to something else. The sheet already has a Sort property so adding a Sort method will cause problems.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Compile Error. Trying to auto sort

    Quote Originally Posted by Gase View Post
    Forgive me for asking but could someone let me know how I close a thread and rate it?
    To mark Solved : In your original message of the thread, click "Edit", then "Go Advanced", then in "Title" box change to "[SOLVED]", then click "Save Changes"

    To rate answer : In the message you want to rate : in the top right corner above the writer's "Join Date" you will see the message # and a set of scales. Click the scales.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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