+ Reply to Thread
Results 1 to 6 of 6

Auto enter current and preceding dates to table column when sheet opens

  1. #1
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Auto enter current and preceding dates to table column when sheet opens

    Hi,

    I wonder if it is possible to assign a macro to a button to add the current date to an empty excel column cell but also have it first update with missing preceding dates to the column before putting in the final current date. For example, on the attached sheet, the last entered date in column "C" is 7/10/20. The macro must first put in the dates from 7/11/20 all the way to the current date today of 7/16/20. Is this possible?
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Auto enter current and preceding dates to table column when sheet opens

    Hi,

    One way is a sheet event macro. See example below which uses the Double Click event. Click anywhere in the range of dates in column C. It puts today's date in the last cell and then previous dates in the rows above.

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Auto enter current and preceding dates to table column when sheet opens

    Thank you Richard.
    It is not working.
    I got a compile error "End if without block if".

  4. #4
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    438

    Re: Auto enter current and preceding dates to table column when sheet opens

    Quote Originally Posted by Dbroek View Post
    Thank you Richard.
    It is not working.
    I got a compile error "End if without block if".
    Change:
    PHP Code: 
    With Range("C2:C" lLastrow 1) = "=C3-1" 
    to:
    PHP Code: 
    Range("C2:C" lLastrow 1) = "=C3-1" 

  5. #5
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Auto enter current and preceding dates to table column when sheet opens

    That did it! Thanks tax211 for offering to fix Richard's generous contribution.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Auto enter current and preceding dates to table column when sheet opens

    Thanks for the correction.

    I'd originally coded this section with a With..End With block of code and at the last minute decided against.
    I removed the End With but not the With.

    Cheers...

+ 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] auto read column list every time form opens
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2016, 10:08 PM
  2. [SOLVED] Enter dates in one column based on whether dates are consecutive in another column
    By ktbb0312 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-17-2015, 02:03 PM
  3. [SOLVED] Formula to insert text in new column if preceding more than one of the preceding have val
    By aimeecrystalaid in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-04-2013, 11:47 PM
  4. Replies: 0
    Last Post: 05-18-2013, 03:29 AM
  5. [SOLVED] Macro to enter current date on a sheet full with data
    By Tishmimi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2012, 10:40 AM
  6. Replies: 9
    Last Post: 12-09-2011, 04:39 AM
  7. [SOLVED] auto numbering an exel work book sheet everytime it opens or print
    By Rugby Al in forum Excel General
    Replies: 1
    Last Post: 07-19-2005, 02:05 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