+ Reply to Thread
Results 1 to 4 of 4

Applying a macro to a selected range.

  1. #1
    Registered User
    Join Date
    05-06-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    28

    Applying a macro to a selected range.

    Hi All,
    I have a macro which sorts data within a cell. This is working perfectly fine but the only problem with this is that it works only for a single which is selected. How can I apply this macro to range of cells I select using a mouse. Any help is much appreciated!!!.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Applying a macro to a selected range.

    Hi,

    Are you able to share the workbook with us and describe in a narrative what you want to do.

    What is QuickSort? I see no definition.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying a macro to a selected range.

    The problem seems to be that in sub SortVals you are operating on ActiveCell throughout the code, instead of the cell that is being passed in as an argument. So you are going to sort the upper-left cell of Selection over and over again. See changes in red.

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Applying a macro to a selected range.

    Thanks for the rep! If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved.

    Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Applying code to the 'selected' cells only
    By CXsjr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-14-2013, 02:49 AM
  2. [SOLVED] Applying If in macro to range of data
    By johnlynches in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2012, 04:13 PM
  3. applying macro code to a range of cells
    By just-gal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2009, 02:26 PM
  4. Applying a macro over a range/selection
    By HydroXidE1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2009, 06:02 AM
  5. applying a macro for a specific field to a range of fields
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2005, 01:05 AM

Tags for this Thread

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