+ Reply to Thread
Results 1 to 8 of 8

Copy Cells to Different Sheets based on a criteria column

  1. #1
    Registered User
    Join Date
    06-05-2017
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    4

    Copy Cells to Different Sheets based on a criteria column

    Hi,

    Just recently joined as I've been struggling to find information on how I can optimise my daily workflow. I've been searching on google and other forums for a few days now and couldn't find any workable information for what I'm trying to do.

    Here goes:

    Basically, I manage Purchase Orders for different Vendors. From our SAP System, I can extract a table with the purchase and vendor data I need. I then paste into a "SAP Import" sheet in my template to begin my work.

    In the leftmost column, there is a reference number that I need to be copied and pasted to the leftmost column of different existing sheets based on the vendor number in the 5th column.

    The sheet names correspond to the Vendor Names. I also have another sheet "Vendor Master" where the vendor numbers and names are listed. The vendor sheets are named exactly as what I have in "Vendor Master".

    At present, I filter the Import sheet and copy and paste the visible cells for each vendor one at a time to the vendor sheets. I've already set up the vendor sheets with vlookups as each vendor requests varying sets of information in various formats. It's taking a huge chunk of my day and leave me little to no time left for my other tasks.

    Ideally, I'd want VBA code that I can run off of a module.

    Many thanks to anyone that can contribute!

    PS: I am just starting to read up on VBA and Macros so hopefully I'll be able to "pay it forward" in the near future!

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

    Re: Copy Cells to Different Sheets based on a criteria column

    'SHEET1 TO MANY SHEETS
    Here's a macro for parsing rows of data from one sheet to many sheets named for the same values in a specific column.It not only can parse the rows, it can create the sheets if they are missing. There is a sample sheet there where you can test this out.
    Last edited by JBeaucaire; 12-26-2019 at 03:44 PM.

  3. #3
    Registered User
    Join Date
    06-05-2017
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: Copy Cells to Different Sheets based on a criteria column

    Hi JBeaucaire!

    Many thanks for the link. In a world where all my vendors accept the same format, I could make this work. However, they all want a specific format for the reports, that's why I only want the reference number in the left most column copied over to their respective sheets. Is there a way I can modify this to just copy that?

    Cheers!

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

    Re: Copy Cells to Different Sheets based on a criteria column

    Yes, the section in middle of the loop is where the copying magic happens. I'm copying entire rows of data, but you could just as easily reduce that to a single cell from each row...

  5. #5
    Registered User
    Join Date
    06-05-2017
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: Copy Cells to Different Sheets based on a criteria column

    I'm guessing this bit is for the copying:

    Please Login or Register  to view this content.
    What edit should I make to make it copy just the left most cells?

    Cheers!

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

    Re: Copy Cells to Different Sheets based on a criteria column

    So this copies entire rows and pastes into column A of the target sheet at the next empty row. If you only wanted to copy A, B and C, you could adjust like so:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-05-2017
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: Copy Cells to Different Sheets based on a criteria column

    Hi,

    I tried replacing the code with these lines you posted.

    Quote Originally Posted by JBeaucaire View Post
    So this copies entire rows and pastes into column A of the target sheet at the next empty row. If you only wanted to copy A, B and C, you could adjust like so:
    Please Login or Register  to view this content.
    What happens is, when I run the module, all of the values in columns A to C gets copied to all the sheets.

    EDIT: The error occured when the lookup value in the column I set for vcol is a String. If I set it to a column with numbers, it works. But then the Sheets are named as the number instead of the Vendor Names which I wanted.
    Last edited by tahlzair; 06-08-2017 at 08:26 PM. Reason: Retest

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,905

    Re: Copy Cells to Different Sheets based on a criteria column

    Best thing to do is to post an example file without sensitive info that reflects current situation.
    Add before and after sheet so the final result is shown.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ 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. Copy Data from multiple sheets based on criteria in a column and paste to master log.
    By Jsonic5280 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2016, 03:55 PM
  2. [SOLVED] Copy data from column to other sheets, based upon vlookup/criteria on column a
    By jedemeyer1 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-27-2013, 04:01 AM
  3. Macro to copy rows based on column criteria to a new sheets
    By Scott821 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2012, 01:55 AM
  4. [SOLVED] Copy Cells In One Column Based On Criteria In Another Column
    By hgteros in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-14-2012, 06:07 PM
  5. Copy Cells to another sheet based column criteria
    By Newfibot in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2011, 01:29 PM
  6. Copy Cells into Blank Invoice Based on Row and Column Criteria
    By alton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2010, 12:49 PM
  7. copy certain cells to 1 of 2 sheets, criteria based
    By ramseyprescott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2010, 01:11 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