+ Reply to Thread
Results 1 to 14 of 14

Dynamic Sort Macro

  1. #1
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329

    Dynamic Sort Macro

    Hello.

    I want to create a sort macro that is dynamic. Today the macro looks like this:

    Please Login or Register  to view this content.
    I want to have the range dynamic so that I can use the same code for several sort criterias?
    Like this:
    Please Login or Register  to view this content.
    I guess it is quite easy to create this but I need help from someone more experienced.

    /Anders

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Add the following to your existing code ...

    Please Login or Register  to view this content.
    HTH
    Carim
    Last edited by Carim; 12-18-2006 at 08:02 AM.

  3. #3
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    thanks Carim.

    Is there a way for me to send the actual Column when I click on the button that triggers tha macro to start?
    I don't want the column to be "hardcoded"
    /Anders

  4. #4
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    It can be anything you need, retrieved from any cell of your worksheet ...
    Range("A1").Value

    HTH
    Carim

  5. #5
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    Hello.

    I guess I need to explain how I really will use this macro.

    I have several buttons on a sheet that starts different sortmacros. All are the same it is just the sorting cell that is different.

    Instead of using 15 macros I want to only use one and determain which cell to use when I start the macro by clickin on one of the buttons.
    When I try to write Sort(S7) excel tells me that it is too complex and it doesn't work. Can I maybe use a cell and use a "onclick" to send the reference I want to use in the macro?

    Any ideas?

    /Anders

  6. #6
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    How do you want to determine your sort cell in your 15 different cases ...?

    Carim

  7. #7
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    I want to pass the cell reference to the subroutine if possible.

    When I click the button/text/cell or whatever I want the macro to start.
    In A4 I have a text that says "SORT". When I click on "SORT" I want the click to start the macro and send the cell reference A4 to the function.

    I don't know how.

    /Anders

  8. #8
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Ok then ...

    Have a try with ...

    Please Login or Register  to view this content.
    HTH
    Carim

  9. #9
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    That might work.
    How can I trigger the function? Is there some easy way?
    Can I use a hyperlink to start a macro? That would be nice because it will be easy to format.

    /Anders

  10. #10
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Well, this line is to be inserted in your existing macro ...

    Carim

  11. #11
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    I'll try.....

    Thanks!

    /Anders

  12. #12
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Anders,

    If following can help ... as a recap ...

    Please Login or Register  to view this content.
    Assigning a short key will make it easier to your users ...

    HTH
    Carim

  13. #13
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329
    Hi.

    It worked great..

    Thank you very much!

    /Anders

  14. #14
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Glad it fixed your problem

    Thanks for the feedback

    Carim

+ 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