+ Reply to Thread
Results 1 to 8 of 8

Macro to pull data from one sheet to another based on higher/last number used

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    27

    Macro to pull data from one sheet to another based on higher/last number used

    Hi,

    I'd like some help to create an easier way to pull specific rows from a sheet to another sheet based on the higher number of a client record.
    My tables/reports are huge and usually have over then thousand rows and more than twenty columns too and copy/paste/filter/delete etc.... takes forever.
    If you can help, please see attached excel sample.

    Thanks
    Jake
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Macro to pull data from one sheet to another based on higher/last number used

    How about
    Please Login or Register  to view this content.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to pull data from one sheet to another based on higher/last number used

    Or this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Macro to pull data from one sheet to another based on higher/last number used

    Hi JJ,

    In a newer version of Excel there is a newer tool called Power Query, or Get & Transform. It can do all of its processes in memory and very fast. If you had a newer version of Excel it is about 10 mouse clicks to do your problem. Here is the Power Query Code and attached file showing what the result is. Time to upgrade to Excel 365?

    Please Login or Register  to view this content.
    Note: I didn't need to type any of the above code as it was created using mouse clicks and the PQ editor.

    Copy Highest using PQ.xlsx

    To have my solution above to work correctly, as Orrin has pointed out it needs some work. It is wrong as given above. BUT if you sort the top table by the first column using Descending (big values to the top) SAVE THE FILE TO DISK and then refresh the query it agrees with the other answers. Power Query works in memory from looking at the file that is stored on the disk/cloud. This seems to be what makes it faster. (?) Just sorting it using Descending within the Power Query editor isn't enough!! I wonder if this is ok for the OP?
    Last edited by MarvinP; 04-24-2018 at 04:06 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    05-17-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Macro to pull data from one sheet to another based on higher/last number used

    Thanks.
    It Looks like is working, but I'm trying to figure out how to add into my real data since I don't know much about the coding I see .
    I put to test in the excel sample I attached and it missed the last yellow highlight.
    In my data, the info are in different columns than the sample, like Client Number may be in column CV and Record in column D.
    Where to I change to check the correct columns ?
    Also, how to I keep the header when it copies to Sheet 2 ?

    Thanks

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Macro to pull data from one sheet to another based on higher/last number used

    The code I supplied missed the last highlighted rows because they are the same Client Number as the first row, which has a higher record number.
    If I've misunderstood you, try the code from xladept which may better meet you needs, or alternatively the suggestion from MarvinP

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to pull data from one sheet to another based on higher/last number used

    Here's a commented routine with column variables to be entered by you for the "real data" - I've also included a short function to find the column numbers fr CV is column#100:

    Please Login or Register  to view this content.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Macro to pull data from one sheet to another based on higher/last number used

    Hi JJ,

    Any chance you can upgrade your version of Excel and get the newer tools?

+ 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. Loop to copy rows of data to another sheet if version number is higher
    By mattyfaz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2015, 11:55 PM
  2. MACRO to Pull Data from multiple worksheets onto a summary sheet based on an ID
    By eswonson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2013, 03:31 PM
  3. Replies: 1
    Last Post: 09-04-2013, 02:07 PM
  4. Replies: 19
    Last Post: 05-13-2013, 01:08 PM
  5. Need Macro to pull data from one excel sheet to another based on a job# and comparing date
    By electromattnic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2013, 04:10 AM
  6. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 AM
  7. Replies: 7
    Last Post: 03-22-2010, 05:22 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