+ Reply to Thread
Results 1 to 3 of 3

Adding Date in VBA?

  1. #1
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Adding Date in VBA?

    Ok so I have two workbooks, in one workbook my macro works perfectly and this is what its supposed to do:

    It moves to a certain sheet and pastes what I have copied to the last open row. Then in column A of the last row where the stuff was pasted, it puts the date.

    It works fine on my one workbook, but I have a similar workbook where I wanted to do the same thing, and it does the pasting part, but its not adding the date. Anyone see any problems with this code:

    Sheets("Line").Select
    lMaxRows = Cells(Rows.Count, "B").End(xlUp).Row
    Range("B" & lMaxRows + 1).Select
    ActiveSheet.Paste
    lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A" & lMaxRows + 0).Value = Date
    Sheets("Daily").Select

    Application.CutCopyMode = False

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Adding Date in VBA?

    No, nothing obvious. Recommend removing the '+ 0'. It should work, but why have it? And then stepping through the code to see what value you are getting for IMaxRows (maybe there is a cell way at the bottom of column A?)
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Adding Date in VBA?

    maybe you should work with below solution

    Please Login or Register  to view this content.
    Last edited by hulpeloos; 01-18-2013 at 01:43 PM.

+ 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