+ Reply to Thread
Results 1 to 4 of 4

Excel VBA: Update rec if it exists, add record if it doesn't

  1. #1
    Registered User
    Join Date
    12-30-2013
    Location
    Missouri, United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Exclamation Excel VBA: Update rec if it exists, add record if it doesn't

    I have 2 wkshts (diff wkbk's), "CurrentTracking" and "MasterTracking". "MasterTracking" is a wksht that will continually be updated and added to for the duration of a project (months); updates and new records to come from "CurrentTracking". "CurrentTracking" is a download from a freight companies website (only goes back about 45 days) with the status of a tracking # current as of the day it's downloaded.

    I need a macro that will update the current status of a record on the "MasterTracking" based on what's on the "CurrentTracking". However, if the record doesn't exist on "MasterTracking", a new record should be added to "MasterTracking". The update process will be run 3+ times a week.

    The unique field in both wkshts is the tracking #. The number of records in the "CurrentTracking" varies from download to download, and as I mentioned the "MasterTracking" will be added onto throughout the project.

    Thoughts on how to do this easily?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel VBA: Update rec if it exists, add record if it doesn't

    Go through the data in the CurrentTracking file, trying to see if there's a matching tracking # in the MasterTracking worksheet.

    If there is update MasterTracking from CurrentTracking, if there isn't add the data from CurrentTracking below the existing data in MasterTracking.

    That would be one way to proceed.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-30-2013
    Location
    Missouri, United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel VBA: Update rec if it exists, add record if it doesn't

    The idea you presented is exactly what I was already thinking. I just don't know how to write that out in a VBA macro. None the less, thank you for the post.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Can you post details of your actual?

    For example, which worksheets in the workbooks are you copying from/to?

+ 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. Goto Record when Duplicate Record Exists
    By rlsublime in forum Access Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2012, 11:13 AM
  2. Help with vba, if record exists overwrite ?
    By vsantoro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2011, 01:12 PM
  3. Function to show if a new error record exists
    By Supply_Analyst811 in forum Excel General
    Replies: 7
    Last Post: 12-08-2010, 03:37 PM
  4. Update excel record to existing DBtable
    By waka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2009, 11:13 PM
  5. If a record exists on a different worksheet....
    By inno101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2007, 03:27 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