+ Reply to Thread
Results 1 to 6 of 6

Macro to copy specific entries and adjust value based on a table

  1. #1
    Registered User
    Join Date
    10-15-2012
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Macro to copy specific entries and adjust value based on a table

    Hi All,

    Happy Holidays everyone!!

    I could use some help with the following goal. In the attached file, I have an Import tab that shows 5 columns. I need a macro that only copies entries where the value in column D is equal to one of the values in the Adjustment Table tab.

    So in this case, whenever a row with a value G, H, or J in column D, the macro copies the row into the Export tab, and adjusts it based on the value next to the adjustment name. So in this case, all entries with "G" in column D will have their "E" column adjusted with an increased 2.2%, and placed into the Export tab.

    I think the example in the attachment will make more sense.

    Can anyone assist me with this?

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Macro to copy specific entries and adjust value based on a table

    How about

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Macro to copy specific entries and adjust value based on a table

    You could use something along these lines.
    Please Login or Register  to view this content.
    See attached workbook
    Attached Files Attached Files
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  4. #4
    Registered User
    Join Date
    10-15-2012
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Macro to copy specific entries and adjust value based on a table

    Thanks for both of your responses! I have tested them and they both work great!

    I have one quick question, is there an easy way to sort the macro output in the Export tab after it has finished generating the lines? Smuzoen, I noticed your macro automatically sorts the output entries by the Name order, which is great. If the need came up for example, could I sort it first by Name and then by Store and then by Date?

    Thank you both again!

  5. #5
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Macro to copy specific entries and adjust value based on a table

    It was only a coincidence that it sorted by Name as your workbook was sorted. I added an extra sub to sort however I was not sure which column was Store - I assumed column C was store so you will need to adjust sort macro as required. I added code to clear the output from Export sheet prior to data being copied across as well. See attached workbook V2.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-15-2012
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Macro to copy specific entries and adjust value based on a table

    This is excellent!!

    Thank you so much smuzoen!

+ 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