Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to insert date stamp into a cell if ticked a checkbox in Excel?

Normally, you enter a date stamp by using hotkeys in Excel. How about insert date stamp into a cell by a checkbox in Excel? When ticking the checkbox, the time stamp is inserted into a specified cell automatically. This article will help you to solve it.

Insert date stamp into a cell if ticked a checkbox with VBA code

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

arrow blue right bubble Insert date stamp into a cell if ticked a checkbox with VBA code


This section will introduce a VBA script to help you insert a date stamp into a cell automatically if ticked a checkbox in Excel. Please do as follows.

1. After inserting a check box, press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy and paste the below VBA code into the Module window.

VBA code: Insert date stamp into a cell if ticked a checkbox

Sub CheckBox_Date_Stamp()
Dim xChk As CheckBox
Set xChk = ActiveSheet.CheckBoxes(Application.Caller)
With xChk.TopLeftCell.Offset(, 1)
    If xChk.Value = xlOff Then
        .Value = ""
    Else
       .Value = Date
    End If
End With
End Sub

3. Press Alt + Q keys to close the Microsoft Visual Basic for Applications window.

4. Right click the check box, and select Assign Micro from the right-clicking menu. See screenshot:

5. In the Assign Macro dialog box, select CheckBox_Date_Stamp in the Macro name box, and then click the OK button. See screenshot:

When ticking the check box, the date stamp will be inserted into the adjacent cell automatically.


arrow blue right bubbleRelated articles:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mehpire · 1 years ago
    how do i get the date stamp to be displayed under my check box?
  • To post as a guest, your comment is unpublished.
    Amy H · 1 years ago
    Hi! Thanks for the code. It works perfectly with a lil tweaking on the offset. However, i was working on a sheet which has many many manyyy rows (~500+ rows) which contains load of check boxes and the file size grew significantly. Is there any way to reduce the size? Any alternative way to do this?

    Thanks!
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good da
      If there are lots of check boxes in rows and you want to act on all check boxes at the same time, the below VBA code can help you.
      Please copy the codes into a Module code window, go back to the worksheet and create a button (such as a Button (Form Control)), assign the macro SetAllChkChange() to the button, then click the button to run the code.

      Now all check boxes in rows of your worksheet have been activate. You can check any one of them to insert date stamp in its adjacent cell.

      Sub SetAllChkChange()
      Dim xChks
      Dim xChk As CheckBox
      Dim xI As Long
      On Error Resume Next
      Erase xArrChk
      Set xChks = ActiveSheet.CheckBoxes
      ReDim Preserve xArrChk(1 To xChks.count)
      xI = 1
      For Each xChk In xChks
      xChk.Select
      Selection.OnAction = "ObjChkChange"
      Next
      End Sub


      Sub ObjChkChange()
      Dim xChk As CheckBox
      Set xChk = ActiveSheet.CheckBoxes(Application.Caller)
      With xChk.TopLeftCell.Offset(, 1)
      If xChk.Value = xlOff Then
      .Value = ""
      Else
      .Value = Date
      End If
      End With
      End Sub
  • To post as a guest, your comment is unpublished.
    Mallory V · 2 years ago
    I copy & pasted the VBA code exactly, but on my spreadsheet, the date appears in the cell above and to the right of the check box column, not in the cell directly to the right. ?
    • To post as a guest, your comment is unpublished.
      Jacob W · 1 years ago
      This is what I did to fix that issue

      Sub CheckBox_Date_Stamp()
      Dim xChk As CheckBox
      Set xChk = ActiveSheet.CheckBoxes(Application.Caller)
      With xChk.TopLeftCell.Offset(1, 1)
      If xChk.Value = xlOff Then
      .Value = ""
      Else
      .Value = Now()
      End If
      End With
      End Sub
    • To post as a guest, your comment is unpublished.
      CW · 2 years ago
      I am also having that exact same issue. "HELP! I need somebody HELP! Not just anybody HELP! You know I need someone HELP!
      • To post as a guest, your comment is unpublished.
        Kev · 2 years ago
        I had the same issue with the date and time stamp appearing in the cell above the intended cell (using Excel 2007). I went ahead and altered the "offset" formula so that it goes over one cell AND down one cell and now the stamp is appearing where I want it: With xChk.TopLeftCell.Offset(1, 1)
        I am updating a worksheet that someone else created and didn't create the checkboxes, but it may have to do with where inside the cell the check box is placed. I got different results when I lined up the checkbox with the bottom of the cell.

        Hope that helps!
      • To post as a guest, your comment is unpublished.
        crystal · 2 years ago
        Good day,
        The code works well in my case. After checking the check box, the date will appear in the cell directly to the right. Would you provide a screenshot of your case. And which Office version do you use. Thank you.
  • To post as a guest, your comment is unpublished.
    June · 2 years ago
    HI I tried this formula and it worked only for A1 and B1 when I applied the macro to to the checkbox in A1. However, when I applied the macro to the checkbox in A2, nothing happened in B2. Also how would the formula be changed if I wanted to use this for a checklist? If column A was the checkboxes and column C was completed date.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good Day,
      Please assign the macro individually to each checkbox.
    • To post as a guest, your comment is unpublished.
      Miriam Alfy · 2 years ago
      Hi:) you can copy the cell with the checkbox in A1 to the rest of the column. or assign the macro individually to each checkbox
  • To post as a guest, your comment is unpublished.
    Sarah T · 2 years ago
    Is there any way to do this with the date AND time? Thanks for the info either way!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi,
      Please apply below VBA code to add date and time.

      Sub CheckBox_Date_Stamp()
      Dim xChk As CheckBox
      Set xChk = ActiveSheet.CheckBoxes(Application.Caller)
      With xChk.TopLeftCell.Offset(, 1)
      If xChk.Value = xlOff Then
      .Value = ""
      Else
      .Value = Now()
      End If
      End With
      End Sub
    • To post as a guest, your comment is unpublished.
      Benoit T · 2 years ago
      Sub CheckBox_Date_Stamp()
      Dim xChk As CheckBox
      Set xChk = ActiveSheet.CheckBoxes(Application.Caller)
      With xChk.TopLeftCell.Offset(, 1)
      If xChk.Value = xlOff Then
      .Value = ""
      Else
      .Value = Date & " " & Time
      End If
      End With
      End Sub
  • To post as a guest, your comment is unpublished.
    Ines · 2 years ago
    Thank you, this was very helpful, I would like to note that I find it more useful to have the date stamp to the left of the check box. to do this you just change the offset to (, -1)