+ Reply to Thread
Results 1 to 5 of 5

Trying to sort results before pasting (where to insert "sort code")

  1. #1
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Trying to sort results before pasting (where to insert "sort code")

    Good evening.
    I have two lines of code that work great. I copy specific columns from Sheet1 and the results are pasted to different columns in Sheet2 (code included below). However, I'd like to sort the results (by column "E" and then "L") before they are posted to Sheet2. I'm new to VBA, so I'm not sure how to insert a sort function before the pasting begins, given the code below. It appears my code is both copying and pasting. Thoughts?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Trying to sort results before pasting (where to insert "sort code")

    Have you tried the macro recorder? Just start macro record and do the sorting on column E, and then try to amend the code from there.
    多么想要告诉你 我好喜欢你

  3. #3
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Re: Trying to sort results before pasting (where to insert "sort code")

    Thank you, Millz. That's a good idea. I didn't know I could turn on the recorder and build mid-code. Actually, is that what I do? Rookie question.

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Trying to sort results before pasting (where to insert "sort code")

    What the recorder does is actually capture what you do and convert it into the VBA equivalent (for most of the actions). If you only performed sorting while recording is on, and then stops recording, the macro would have only the code that would perform the sort.

    I've learnt most of my basic stuff through recording and amending. You should be able to analyse what the recorded code is doing, make some amendments and then put it before your "copy and paste" segment of code.

  5. #5
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Re: Trying to sort results before pasting (where to insert "sort code")

    Thank you very much! I've certainly underestimated the power of the recorder. But not after tonight. Have a nice evening.

+ 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. 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
  2. Replies: 7
    Last Post: 11-28-2006, 04:19 PM
  3. Excel "mode" function returns different results based on sort orde
    By Mark Neuffer in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-25-2006, 03:20 AM
  4. pictures to work with "data" "sort" option
    By arad in forum Excel General
    Replies: 1
    Last Post: 04-18-2006, 04:15 PM
  5. can I insert a Sort "Button" in a cell within Excel
    By Vicki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2005, 12:05 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