+ Reply to Thread
Results 1 to 6 of 6

VBA to copy data to new column if date doesn't allready exist.

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    moon
    MS-Off Ver
    2013
    Posts
    3

    VBA to copy data to new column if date doesn't allready exist.

    Hello guys, first post here !

    First off I know that there are a lot of similar use cases for my problem but my knowledge is just not good enough to adapt it to my situation .. so here goes ..

    I have a workbook in which the user fills in values in Sheet1 (C5:C20) and at the top of Sheet1 (C2) the user fills in the date.

    Now I would like a vba code to copy the values that have been entered into Sheet1 (C5:C20) to another sheet (Geschiedenis) like this:

    _____A_____B_____C____
    1 | date1 | date2 | date3
    2 | valu1 | valu1 | valu1
    3 | valu2 | valu2 | valu2
    4 | valu3 | valu3 | valu3
    etc...



    and here's the catch.. it has to check for that date (primary key) if there are existing values or not and if there are it should overwrite them.

    I hope I'm making sense and any of you can find the time to help a noob out ..
    My boss would be super-happy :p
    Last edited by steve_jaspers; 02-03-2015 at 10:14 AM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA to copy data to new column if date doesn't allready exist.

    Hi Steve,
    Welcome on the Earth and Excel Forum.
    How is weather on the Moon?

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    01-28-2015
    Location
    moon
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA to copy data to new column if date doesn't allready exist.

    Thans for the quick reply !

    I have attached the workbook and have manually entered into the sheet 'geschiedenis' what I would like to have excel do automatically.

    Once the user presses the 'afdrukken en opslaan' (print and save) button, it should check if there is any data for the date entered in C2, if there is not, add the data to a new line (in the right place date-wise)with the date (C2) on top, if there IS data on the selected date, then it should be overwritten after the user has had a popup window asking him if he wants to overwrite or not.

    I hope it's clear what I mean ...
    Attached Files Attached Files

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA to copy data to new column if date doesn't allready exist.

    Please find the attached sheet. I have inserted another button the sheet1 and assigned the code "CheckAndFillData" to this.
    In this code you can include your code for saving and printing the sheets. Just add your code before the End Sub line of CheckAndFillData code and don't forget to declare variables in the code as well.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-28-2015
    Location
    moon
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA to copy data to new column if date doesn't allready exist.

    Thanks a lot, works like a charm !!!
    Last edited by steve_jaspers; 02-02-2015 at 07:37 AM.

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA to copy data to new column if date doesn't allready exist.

    Great. Glad to know that.

    If that takes care of your question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

+ 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] Code to paste form data to next available row if cb1 value doesn't exist in column a
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2014, 06:20 PM
  2. [SOLVED] Save as macro; File allready exist
    By tigergutt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2013, 09:15 AM
  3. Filtering for a certain date and Having a message pop up if date doesn't exist
    By frenchgreek in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2013, 03:38 PM
  4. [SOLVED] Counting Data Which Doesn't Exist..
    By tommyfernandez in forum Excel General
    Replies: 8
    Last Post: 07-31-2013, 02:28 PM
  5. [SOLVED] Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist
    By pete.bastin@btopenworld.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2006, 01:10 PM

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