+ Reply to Thread
Results 1 to 7 of 7

Insert Current date

  1. #1
    Registered User
    Join Date
    11-12-2007
    Posts
    30

    Insert Current date

    I need a macro that sets the current date in a specific cell.

    In cell A1, for example, I need to put the current date. Whenever you use =today() it only inserts the date it was entered, e.g. it doesn't update every time you open the document.

    I tried creating a macro that enters =today() into the cell A1, but the problem I have is that it would enter the date, but it would put it in whatever cell was selected. This isn't good enough, as it has to be put into a specific cell, for this example A1.

    I need a macro that when it runs (and it ill be be ran everyday) the contents of cell A1 will become the current date.

    I may need to edit this in the future so that I can change the updating cell easily from A1 to a different cell.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    tRY

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    11-12-2007
    Posts
    30
    No it didn't work, but I think I've come up with something:
    Please Login or Register  to view this content.
    I am not a programmer, so I'm not sure how much of this I need. I know that the first line takes you to worksheet "sheet 1" & cell "A1", and that the second line inserts the formula into the active cell, but I have no idea what the third line does.

    Any ideas?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Sorry, there's a typo. It should be

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-12-2007
    Posts
    30
    Thank you very much, that works really well!

    Could you explain to me what the code means? I am still not sure exactly what is happening, I am very new to VBA!

    Also, in the code I came up with, what does the third line mean?

  6. #6
    Registered User
    Join Date
    06-12-2015
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    1

    Re: Insert Current date

    Hello Roy,
    Greetings for the day.

    Please let me know where should I add this "Cells(1, 1).Value = Date" instead of ActiveCell.FormulaR1C1 = "=TODAY()".

    Below is my code -

    Sheets("Details of Build").Select
    ActiveCell.FormulaR1C1 = "=Today()"
    ActiveCell.Next.Select
    Selection.Offset(0, 0).Select

    End Sub

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert Current date

    Please use code tags when posting to the Forum.

    Please Login or Register  to view this content.

+ 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