How to populate date within same cell as checkbox when checked

kmsprague

New Member
Joined
Nov 14, 2022
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I've exhausted my google searches to find answers and am hoping you can help! I'm wanting to use checkboxes to show when each step of a process has been completed, and when the person completes the task and checks the box the date populates within the same cell. Every instruction I've found has shown how to populate the date in the following cell, but not the same cell as the checkbox. Do you happen to know a way to make this happen? Here's what I'm hoping for:

1704490531311.png


Any help is greatly appreciated! Thank you!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try assigning the following macro to your checkboxes:
VBA Code:
Sub Change_Check_Boxes()
    Dim c As Excel.CheckBox, r As Range
    Set c = ActiveSheet.CheckBoxes(Application.Caller)
    Set r = c.TopLeftCell
    If c.Value = xlOn Then r.Value = Format(Date, "mm/dd/yyyy") Else r = ""
End Sub
 
Upvote 0
Try assigning the following macro to your checkboxes:
VBA Code:
Sub Change_Check_Boxes()
    Dim c As Excel.CheckBox, r As Range
    Set c = ActiveSheet.CheckBoxes(Application.Caller)
    Set r = c.TopLeftCell
    If c.Value = xlOn Then r.Value = Format(Date, "mm/dd/yyyy") Else r = ""
End Sub
Hi kevin9999!

This is SO close to working! It's putting the date in the cell above the checkbox instead of within the cell with the checkbox. Thoughts on what to change? I'm still learning code. :)
 
Upvote 0
That'll be because your checkbox top left corner will be in the cell above where it sits - right-click on the checkbox & you'll see what I mean (it's based on the larger/outer square).
Either, you can increase your row height until the top left corner sits on the same row, or if that's not an option, use the following code instead:
VBA Code:
Sub Change_Check_Boxes()
    Dim c As Excel.CheckBox, r As Range
    Set c = ActiveSheet.CheckBoxes(Application.Caller)
    Set r = c.TopLeftCell
    If c.Value = xlOn Then r.Offset(1) = Format(Date, "mm/dd/yyyy") Else r.Offset(1) = ""
End Sub
 
Upvote 1
Solution
That'll be because your checkbox top left corner will be in the cell above where it sits - right-click on the checkbox & you'll see what I mean (it's based on the larger/outer square).
Either, you can increase your row height until the top left corner sits on the same row, or if that's not an option, use the following code instead:
VBA Code:
Sub Change_Check_Boxes()
    Dim c As Excel.CheckBox, r As Range
    Set c = ActiveSheet.CheckBoxes(Application.Caller)
    Set r = c.TopLeftCell
    If c.Value = xlOn Then r.Offset(1) = Format(Date, "mm/dd/yyyy") Else r.Offset(1) = ""
End Sub
I didn't realize my checkbox was above the cell. Thank you so very much! This worked!
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top