+ Reply to Thread
Results 1 to 10 of 10

Macro: Updating data meeting conditions or adding new if not found

  1. #1
    Registered User
    Join Date
    01-08-2019
    Location
    München
    MS-Off Ver
    365
    Posts
    8

    Macro: Updating data meeting conditions or adding new if not found

    Hi all,
    I'm trying to solve this issue for a week now. My code is totaly massed up, so I deleted all of it and want to start from the scratch again.
    I basically got 2 files: 1 import/source file and 1 target file.
    Both files have the columns Date, ID, Test, Purpose, Status.
    When updating the target file, the macro is supposed to only consider entries in the source file with a specific Purpose. For those entries, the macro must then check if the source file's data is already in the target file by considering Date, ID and Test (so basically Date, ID and Test create a unique identifier).
    If the entries do exist in the target file, only the status in the target file should be updated.
    All entries not found should be added at the bottum of the target file.
    There are a couple of solutions for this issue in the web, tried reproducing them, w/o success.
    Do you have an idea how to handle this?
    Thanks a lot in advance!!!
    Last edited by rhanschke; 02-21-2019 at 01:54 PM. Reason: Uploading sample files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Macro: Updating data meeting conditions or adding new if not found

    Can you post copies of both files? De-sensitize the data if necessary.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    01-08-2019
    Location
    München
    MS-Off Ver
    365
    Posts
    8

    Re: Macro: Updating data meeting conditions or adding new if not found

    Thanks for your reply. I updated the original post with both, target and source file. Many thanks in advance!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Macro: Updating data meeting conditions or adding new if not found

    Sorry for the delay. I was having problems with my computer. Your target file has "#N/A" in some cells in column D. The "#N/A" has to be replaced with an actual value or with a zero. This macro will replace them with zero's.
    Please Login or Register  to view this content.
    Place this macro in a standard module in the "target" workbook and then with both workbooks open, run the macro:
    Please Login or Register  to view this content.
    Change the file name (in red) and the sheet names (in blue) to suit your needs.

  5. #5
    Registered User
    Join Date
    01-08-2019
    Location
    München
    MS-Off Ver
    365
    Posts
    8

    Re: Macro: Updating data meeting conditions or adding new if not found

    Thanks a million, Mumps1!!! Amazing how swift and fast this macro works!
    2 last questions:
    a) If I only want to check for the source file's lines with "Purpose 4" how do I need to integrate that?
    Enlarging
    Please Login or Register  to view this content.
    with the additional column "Purpose" (I assume this is done by changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    and adding
    Please Login or Register  to view this content.
    after
    Please Login or Register  to view this content.
    yields a out of range error.
    b) How do I update number of columns and their order? What do I need to change in the code? I.e. the source file has 26 columns with B = ID, C = Date, K = Test, M = Status and R = Purpose, whereas the target file has 18 columns with E = Date, F = Test, H = ID and I = Status.
    If new entries are added to the target file, the following columns of the source file need to be copied to the target file: S to A, T to B, F to C, C to E, K to F, R to G, B to H, M to I.
    Once again: thanks a lot for your support!
    Last edited by rhanschke; 02-22-2019 at 12:42 PM. Reason: Adding another final question

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Macro: Updating data meeting conditions or adding new if not found

    Please attach a version of the 2 files with the additional columns and explain in detail what you want to do.

  7. #7
    Registered User
    Join Date
    01-08-2019
    Location
    München
    MS-Off Ver
    365
    Posts
    8

    Re: Macro: Updating data meeting conditions or adding new if not found

    Thanks, Mumps1! I figure out question b) myself. Not too hard ;-) However, I still can't get my head around question a). Maybe you could assist once more? That'll apply to the sample files I attached previously.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Macro: Updating data meeting conditions or adding new if not found

    Try:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-08-2019
    Location
    München
    MS-Off Ver
    365
    Posts
    8

    Re: Macro: Updating data meeting conditions or adding new if not found

    Works like a charme! Thanks a lot, Mumps1!

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Macro: Updating data meeting conditions or adding new if not found

    You are very welcome.

+ 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. adding a blank row when data found
    By jamesg123 in forum Excel General
    Replies: 3
    Last Post: 11-19-2018, 02:03 PM
  2. [SOLVED] Display last 3 months data meeting conditions
    By JayUSA in forum Excel General
    Replies: 12
    Last Post: 08-14-2017, 08:03 PM
  3. Replies: 0
    Last Post: 05-10-2016, 04:00 PM
  4. Need help updating this macro to not fail when search criteria is not found.
    By programct in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2013, 04:22 PM
  5. Duplication data every time macro is run, instead of updating newly found data only
    By Lostinxcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2010, 03:41 AM
  6. automaticaly copy cell data meeting certain conditions to separate worksheet
    By marc eber in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2008, 05:47 PM
  7. Vlookup a value if blank cell found after meeting two other criteria
    By markmac234 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-28-2007, 06:15 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