+ Reply to Thread
Results 1 to 6 of 6

macro to sort using relative references

  1. #1
    Forum Contributor
    Join Date
    07-24-2013
    Location
    HongKong
    MS-Off Ver
    Excel 2010
    Posts
    237

    macro to sort using relative references

    Dear all,

    ScreenHunter_041.jpg

    I want to write a macro to sort using relative references.
    When I put the cursor at H4 and start the macro, it would sort Row 4:Row 24 using H4:H24 as index.
    When the cursor is at O4, it sorts using O4:O24 as index.

    The problem I meet is that, although relative relative mode is set, it always starts at H4 at which the cursor I first put during recording.


    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: macro to sort using relative references

    You could use this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Forum Contributor
    Join Date
    07-24-2013
    Location
    HongKong
    MS-Off Ver
    Excel 2010
    Posts
    237

    Re: macro to sort using relative references

    Quote Originally Posted by antoka05 View Post
    You could use this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

    Yes! It works as what I want.
    Thank you Antonio

  4. #4
    Forum Contributor
    Join Date
    07-24-2013
    Location
    HongKong
    MS-Off Ver
    Excel 2010
    Posts
    237

    Re: macro to sort using relative references

    Dear Antonio,

    I found your macro only sorts the area from cells A4:P24, but I want to sort all the rows from Row 4 to Row 24.

    Amendment : I got it, it may sort the entire row after the workbook is saved before running the macro,
    Last edited by kent97; 09-19-2016 at 08:48 AM.

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: macro to sort using relative references

    I hope that this code can help you:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  6. #6
    Forum Contributor
    Join Date
    07-24-2013
    Location
    HongKong
    MS-Off Ver
    Excel 2010
    Posts
    237

    Re: macro to sort using relative references

    Quote Originally Posted by antoka05 View Post
    I hope that this code can help you:
    Please Login or Register  to view this content.
    Regards,
    Antonio
    Yes, the Macro may sort the entire row after amended. But I find it also sorts Row 1 to 3, I expect these 3 rows remain intact, only sort w.e.f. Row 4.

    Thanks

+ 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. Absolute references in relative ref macro
    By dillona27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2014, 10:11 PM
  2. Relative references, record macro, excel
    By tharex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2013, 11:57 AM
  3. Macro relative references
    By JensPeter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2010, 12:33 AM
  4. Sort data containing relative references
    By lax828 in forum Excel General
    Replies: 2
    Last Post: 01-07-2010, 05:05 PM
  5. [SOLVED] How to make a macro with relative references
    By Hall in forum Excel General
    Replies: 4
    Last Post: 03-16-2006, 11:00 PM
  6. [SOLVED] Relative references and macro programming
    By Ruth in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  7. [SOLVED] macro vba relative references
    By aut1jlt in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-20-2005, 02:06 PM

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