+ Reply to Thread
Results 1 to 6 of 6

Update if exist,otherwise insert

  1. #1
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Update if exist,otherwise insert

    Hello dear members.

    I got one situation and I will try to explain it.

    I got excel file with two sheets (Sheet 1-Template, Sheet 2-DB). Template is used by manager who appoints yearly targets on monthly base. After state and approve the targets the data will be copy and pasted into DB. But sometimes manager can change targets after approve step.

    In this point I need that if the data stated on Template exist on DB, Update, otherwise insert new lines. Actually I wrote code to insert lines but I couldn't write the proper code for check. Please help me on this issue.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Update if exist,otherwise insert

    See what i read your question

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mohan.r1980; 01-16-2019 at 02:24 AM.
    Regards,
    MohanS


    "Perfection is not attainable, but if we chase perfection we can catch excellence." - Vince Lombardi

    You can simply say thanks by clicking "*Add Reputation" icon

  3. #3
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Update if exist,otherwise insert

    Mohan.r1980 I am so grateful to you for your code, really appreciate it. Actually code works when I add targets for the first time. But if I want to update the previous data I got "run-time error 1004" and code shows the problem for
    Please Login or Register  to view this content.
    . Please help me to solve that problem.

  4. #4
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Update if exist,otherwise insert

    Hi Medex,

    find below updated code

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Update if exist,otherwise insert

    Mohan.r1980 your code works perfectly. you'r are really so talented. Thanks a lot for your support.

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Update if exist,otherwise insert

    Your welcome dear and thanks for rep

+ 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. Insert rows if value doesn't exist
    By S1n1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2016, 05:18 AM
  2. Code to update or insert if doesnt exist
    By bosco2 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-26-2015, 03:29 AM
  3. Replies: 10
    Last Post: 09-24-2010, 06:20 AM
  4. Insert row if text doesn't exist
    By murzyn1975 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2009, 04:49 AM
  5. search for worksheet, insert new if doesn't exist
    By cereldine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2006, 12:15 PM
  6. [SOLVED] Insert if not exist
    By SG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2005, 02:05 PM
  7. [SOLVED] How do i insert lines into a worksheet depending on if data exist.
    By Nutter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2005, 12:06 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