+ Reply to Thread
Results 1 to 6 of 6

quick sort question - vba

  1. #1
    Registered User
    Join Date
    08-02-2013
    Location
    phoenix
    MS-Off Ver
    Excel 2007
    Posts
    16

    quick sort question - vba

    im trying to sort using vba, i have the code to select the cell i want to start with.

    i want to use xlDown and xlToRight to select my range.

    heres my code, how can i make it work?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: quick sort question - vba

    Try

    Please Login or Register  to view this content.
    It's a good idea to set the value of Header to xlYes or xlNo in case the guess is wrong.

  3. #3
    Registered User
    Join Date
    08-02-2013
    Location
    phoenix
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: quick sort question - vba

    Quote Originally Posted by mrice View Post
    Try

    Please Login or Register  to view this content.
    It's a good idea to set the value of Header to xlYes or xlNo in case the guess is wrong.

    Im a rookie with vba so im not too sure what your last sentence means? sorry.

    also im still erroring out when executing the code, i get run time error 1004 Method 'Range' of object'_Global' failed

    did the code execute on your end?

    thanks for the help!

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: quick sort question - vba

    Try with less brackets

    Please Login or Register  to view this content.
    Excel will make a guess as to whether there is a header row in the range or not based upon the cell contents. Sometimes it gets it wrong hence the suggestion you should specify if there is a header row or not.
    Last edited by mrice; 09-24-2013 at 03:46 PM.

  5. #5
    Registered User
    Join Date
    08-02-2013
    Location
    phoenix
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: quick sort question - vba

    Quote Originally Posted by mrice View Post
    Try with less brackets

    Please Login or Register  to view this content.

    perfect! code is flawless. thanks for the help!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: quick sort question - vba

    The ActiveCell is on the ActiveSheet. If you want to use that in figuring out what to sort, you need to select the sheet first.
    Entia non sunt multiplicanda sine necessitate

+ 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] Quick question about automatic row deletion (should be very quick and easy!!)
    By poptart141 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-09-2013, 12:56 PM
  2. Can I "auto-sort" or use a quick button to sort?
    By drewkloc71 in forum Excel General
    Replies: 4
    Last Post: 09-07-2009, 03:14 AM
  3. quick sort code
    By bceng in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-25-2008, 04:55 PM
  4. Quick Question QUick Answer
    By ccraig61 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-25-2006, 09:34 PM
  5. Quick question - quick answer about assigning shortcut keys
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2005, 06:05 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