+ Reply to Thread
Results 1 to 9 of 9

Need macro to sort and feed data

  1. #1
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Need macro to sort and feed data

    I need a macro that will sort FileA by Policy Number (Column A), and send the last data row for each column after sorting step to File B. Therefore FileB would have one row per policy number. My files are attached for calrity. I hope someone out there can help me with this. Thanks in advance for your help.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need macro to sort and feed data

    send the last data row for each column after sorting step to File B.
    You mean the last entry per policy number should be sent to File B?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Need macro to sort and feed data

    yes! last entry per policy should be sent to fileB

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need macro to sort and feed data

    Try this code. Paste it in a standard module (see steps after the code) in FileA.xlsm.
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

    I have sorted on column A. Let me know if any other fields need to be sorted.

  5. #5
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Need macro to sort and feed data

    Thanks, this works great but for one little thing. Both files will usually be closed at the point of process. The process will be initiated by button on a thrid workbook. Could you please modify the code to work even whether or not files A & B are opened or closed.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need macro to sort and feed data

    Arlu's code designed to be run from a third source:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need macro to sort and feed data

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  8. #8
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Need macro to sort and feed data

    Havent tried it yet, will try it right now

  9. #9
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Need macro to sort and feed data

    Hats off to both of you, thanks for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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