+ Reply to Thread
Results 1 to 10 of 10

automatically filling columns

  1. #1
    Forum Contributor
    Join Date
    08-10-2006
    Location
    The Netherlands
    MS-Off Ver
    Office for Mac 2016; MS Office 2016 for Windows
    Posts
    110

    automatically filling columns

    Hi All,

    I've attached a file with 2 tabs.
    First tab "PO_Summary" has a PO number, Qty and a Part in column A, B and C. A part can occur multiple times with different PO numbers.
    Second tab "PO_Detail" has a PO number and a Part in column A and B.

    What I would like to have automated, is the filling of the PO numbers in the "PO_Detail" tab with the corresponding PO numbers from the first tab "PO_Summary".
    The parts in the 2nd tab (column B) are copied / paste from an original file, also with the correct amount of lines.
    So in the attached file, you see part ABC occur 5x with PO 123, part DEF occur 10x with PO 456 and part ABC again for 15x with PO 789. In the second tab, column B is then already filled with 5x ABC, 10x DEF and 15x ABC.

    The macro will now need to fill the first column A of the second tab with 5x 123, 10x 456 and 15x 789.

    Is there any quick and easy way to program this?

    Many thanks in advance for your time and assistance, if the above is not clear, please let me know!

    Kind regards,
    Peter
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: automatically filling columns

    Hi - a combination of Index and Match should work here unless there is any specific need of looking for a macro:

    Use this formula in cell A3 and drag it all the way down:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    since you have ABC appearing in cell C3 and C5 of PO_Summary tab, you will not see 789 in the PO_Detail sheet (since lookups take into account the first result). Howeve, in real data, I assume such cases wont exist.

    Hope this helps.
    If solved kindly remember to mark Thread as solved.
    Click the small star icon at the bottom left of my post if this was useful.

  3. #3
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: automatically filling columns

    Just in case a code is required:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-01-2012
    Location
    Istanbul
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: automatically filling columns

    Hi kbkumar!
    I recently joined the forum and now noticed a simple point, that I was long struggling with:
    I always had hard time referencing cells in loops with counters.
    Macro recorder suggests the use of Range("A1") by default and I always tend to use the Cells(1,1) format.
    From your message above I understand that the correct way to reference Range is as in example:

    Please Login or Register  to view this content.
    Is that true or are there other forms that can be of better use in such loops?
    Thank you in advance!

  5. #5
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: automatically filling columns

    Hi Cinarbe,

    Welcome to the forum. I am afraid to say that you will have to start a new thread for your query to be compliant with the forum rules.

    Thanks.

  6. #6
    Forum Contributor
    Join Date
    08-10-2006
    Location
    The Netherlands
    MS-Off Ver
    Office for Mac 2016; MS Office 2016 for Windows
    Posts
    110

    Re: automatically filling columns

    Hi kbkumar,

    Thanks for your time looking into this.

    Your formula is partially working, as indeed I would need to see the 789 in the PO_Detail sheet as well...
    So the first 5 lines of part ABC need to show 123, then part DEF needs to show 456 (which is happening perfectly with your INDEX formula).
    However, then the next 15 lines of ABC would need to show that specific PO number 789 from the PO_Summary sheet...
    And with your formula, it is showing the 123 PO again.

    So hopefully there is something that can be done to fix this...

    Appreciate your time and help in this!!!

    Regards,
    Peter

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: automatically filling columns

    Hi Peter, try this
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-10-2006
    Location
    The Netherlands
    MS-Off Ver
    Office for Mac 2016; MS Office 2016 for Windows
    Posts
    110

    Re: automatically filling columns

    Hi Nilem,

    Perfect, thanks!!

    Quick additional question, if I want to insert columns in the PO_Summary sheet, so that PO# will be column D, Qty column G and PN column H (instead of the current columns A, B and C in the testfile) what changes do I have to make in your code to have it working?
    Just trying to understand what the code is doing exactly...

    Thanks again!!

    Regards,
    Peter

  9. #9
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: automatically filling columns

    a few changes
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    08-10-2006
    Location
    The Netherlands
    MS-Off Ver
    Office for Mac 2016; MS Office 2016 for Windows
    Posts
    110

    Re: automatically filling columns

    Perfect!!! Many thanks!!!

    Star added ;-)

    Regards,
    Peter

+ 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