+ Reply to Thread
Results 1 to 8 of 8

VBA/Macro to copy data from 1 sheet to another based on values in a specific column

  1. #1
    Registered User
    Join Date
    05-20-2019
    Location
    North Georgia
    MS-Off Ver
    2013
    Posts
    4

    Question VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    Hi! I am extremely new to the VBA/Macro world. I need to write some code to help me with a daily report that I turn in to all of the higher ups at my company.

    Sheet 1:ShippedOrders will have a list of our orders that shipped out the day before, column I. Each order has as many rows as it does product types that shipped. So if order 123 had 4 different product, the order # is listed for 4 rows.
    Sheet 2: Report will have a formatted report that I download from other software. While it should only have the order information that shipped the day before, there are always additional orders that get mixed in for various reasons.
    Sheet 3: Deletions is a list of items that need to be deleted off of Sheet 2: Report before data is sent to Sheet 1: ShippedOrders.


    1st-I need to eliminate all rows that contain any of the phrases on Sheet 3:Deletions via command button possibly.

    2nd-I need a command button(?) that will have Excel look at the orders in column I (Sheet 1: ShippedOrders) and pull that many rows of information from Sheet 2:Report in the order that column I is already in.

    I have attached a file to give you an idea of what I am working with, small scale.

    I really appreciate any help that I can get. Doing this manually takes up so much of my work day that it is hard to keep up with all of my other responsibilities.


    Also: I have been readying up on VBA BUT I am having the hardest time finding a well rounded reference on VBA terminology.
    Attached Files Attached Files
    Last edited by Aprilk; 05-20-2019 at 02:09 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    See the attached file with the codes embedded into the Command Buttons.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-20-2019
    Location
    North Georgia
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    Alan,

    I have a couple of questions if you have a sec.

    If I needed to add more items to Sheet 3: Deletions, would that be a fairly easy task for a beginner?

    I noticed that Transfer Orders button is pulling the allotted number of rows but, it is making say all 4 rows the same data instead of unique rows?


    Thank you so much for your help!

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    If I needed to add more items to Sheet 3: Deletions, would that be a fairly easy task for a beginner?
    Code is set up to find the last row for each sheet so that should not be an issue.

    I noticed that Transfer Orders button is pulling the allotted number of rows but, it is making say all 4 rows the same data instead of unique rows?
    That is because you only have a single line of data for the order in the sheet that we are copying from. Is your workbook a realistic representation of your actual workbook? If yes, then what should the other three rows appear as if not a replication?

  5. #5
    Registered User
    Join Date
    05-20-2019
    Location
    North Georgia
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    Thank you!

    I am attaching snips of what the shipped orders look like after running the code and a snip of what the report looks like when I manually enter the information.
    The amount of order rows on sheet 1 should be consistent with the amount of rows for that order on the 2nd sheet.
    Attached Images Attached Images

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    I understand. I will look at this a bit later. Need to run out for a couple of hours and no time now. I will need to revamp some of the code but it will take a bit.

  7. #7
    Registered User
    Join Date
    05-20-2019
    Location
    North Georgia
    MS-Off Ver
    2013
    Posts
    4
    Quote Originally Posted by alansidman View Post
    I understand. I will look at this a bit later. Need to run out for a couple of hours and no time now. I will need to revamp some of the code but it will take a bit.
    I really appreciate your time, thank you!

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA/Macro to copy data from 1 sheet to another based on values in a specific column

    Ok. I've taken a different approach to this issue. The first Command button stays. The second command button should be disregarded. I have provided a Power Query Solution. Power Query is part of Excel starting with Version 2010. Since you are running 2013, you will need to download the add-in available from Microsoft. Here is the Mcode for the solution.

    First I loaded each of your tabs into Power Query and then merged the two tables based upon the SO Order.

    Please Login or Register  to view this content.
    If you are unfamiliar with PQ, then look at the two links in my signature in Post #2 for a complete explanation and how to employ this. It is very fast and fairly simple to learn. Your file with the PQ solution is attached.
    Attached Files Attached Files

+ 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. [SOLVED] VBA Macro to copy row values (not formulas) to another sheet based on cell data
    By Irishmatty513 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-29-2018, 09:25 AM
  2. Macro based on Cell Data-Copy to Specific Location on Different Sheet
    By blackshag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2016, 06:57 AM
  3. [SOLVED] Macro to copy specific data from one WB to specific cells in another WB based on specific
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 11:05 AM
  4. [SOLVED] Macro to copy date to specific sheet based on data from another sheet.
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-09-2013, 11:28 AM
  5. [SOLVED] Trying to move specific range to a specific sheet based on data in certain column
    By cain2011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-01-2013, 08:09 AM
  6. HELP! Macro to Copy specific cells from one sheet to another based on specific criteria
    By atriscritti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-11-2012, 11:05 AM
  7. Macro to copy a row of data to a different sheet based on a word in a column
    By trav96817 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2012, 09:51 PM

Tags for this Thread

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