+ Reply to Thread
Results 1 to 10 of 10

VBA: Read date and paste the date info on the correct cell. Analyse code please.

  1. #1
    Forum Contributor
    Join Date
    05-09-2013
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    107

    VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Hi all,

    I'm having a big problem that I cannot solve. I have an Excell worksheet1 with assorted data with the correspondence of a date time. The increment is one hour. For each data time I have one value.

    In worksheet two, I have a organized data cells from 2000 until now, with every hours of the day. That means that I have thousands of rows with date. In this worksheet I want a VBA code that can read the correspondent value for each date in the worksheet1, and paste it on the correct date that it is on worksheet2.

    That means that the code must read date format cells. I've trying my best to try to get this working, but I just don't have knowledge to do that.

    In the little example that is attached you can see the macro code that is written. I do not know why the code freezes my computer, and when it finishes I have no results on it..

    In this example I want that the VBA code read the date time in 1st worksheet, get the data of the correspondent B column and then past it on the correct cell date in cell B of worksheet2. I know that I'm not expressing myself in the better way. But if you give a quick look at the code you will understand what I want.

    Please any help appreciated.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    This is a simple Lookup or match and index function. You do not need a code.

  3. #3
    Forum Contributor
    Join Date
    05-09-2013
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Thanks for your answer.

    I've tried that too.. But still no success..

    Can you please tell me how would I do it?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    I think it is a formatting issue. If you look at 01/06/2006 02:00 , both rows should be equal, but they are not. If you format them as general, they appear to be the same: 38869.08333
    But they are not the same; One of them is 38869.0833333333 and the other one is 38869.0833332367.

  5. #5
    Forum Contributor
    Join Date
    05-09-2013
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Good point! That is one problem!

    But correcting that thing, the code still freezes in my computer.. How can I optimize this?

    Thanks

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    As I said, you do not need a code for this purpose, but if you insist, please post the corrected spread sheet and I will write you a faster code, but please note that, as is the case with match function, the code will not work if the dates are not the same.

  7. #7
    Forum Contributor
    Join Date
    05-09-2013
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Dear AB33, I do not insist in writing a code. I'm writing a code because I do not know how to do this without recurring to VBA.

    Can you give me an example on how to do this without code?

    Attach the correct spreadsheet is hard.. because original spreadsheet has about 70mb.. And if you can teach me an faster way without code I will accept and thanks it!

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    If your dates are corrected, put this formula in sheet two, B1 and drag it down

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-09-2013
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    107

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Dear AB33,

    Thank you so much for your knowledge sharing! I've could solve my problem thanks to you!

    Regards!

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA: Read date and paste the date info on the correct cell. Analyse code please.

    Ropbasuel,
    You are welcome!
    Could you please now close (Mark) this thread as solved? Go in to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

+ 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