Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Excel checkbox date question

There may be an easier way, but I'd go at it like this:

Behind the Click event of each check box, I'd put this code:

Private Sub CheckBox1_Click()
If CheckBox1.Value Then Call UpdateDateValue(CheckBox1)
End Sub

Obviously, you'd need to update each Click event to check the
appropriate checkbox's value and pass the reference to it.

Then add the following code somewhere where that Click event can call
it:

Private Sub UpdateDateValue(objCheckBox As MSForms.CheckBox)
With objCheckBox.Parent.Cells(objCheckBox.TopLeftCell.R ow,
objCheckBox.TopLeftCell.Column + 1)
If .Value = vbNullString Then
.Value = Now
End If
End With
End Sub

JimK wrote:
Thanks Mike. This worked, but only for the first checkbox (the one in A1).
Let's say I have a whole column of checkboxes in column A (A1, A2, A3, etc.).
Is there a way that all the checkboxes refer to the same macro, but the
macro "knows" to enter a date in the B cell that's next to the checkbox that
was checked?

"Mike" wrote:

assuming your checkbox is in A1

right click on your checkbox and assign the macro

If Worksheets("Sheet2").Cells(1, 2).Value = "" Then
Worksheets("sheet2").Cells(1, 2).Value = Now()
End If

format the date cell with the custom format mm/dd/yyyy

Mike

"JimK" wrote:

Hi,
I have a checkbox in my worksheet. I'd like the user to click on the
checkbox and this action would populate today's date (mm/dd/yyyy) in the cell
directly to the right of the check box. I'd like the date to be "hardcoded"
and not updated every time the worksheet is opened.
I assume I need a macro to do this, but am not sure of the easiest way. Any
thoughts would be greatly appreciated.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox Question slow386 Excel Discussion (Misc queries) 7 July 21st 07 12:06 AM
CheckBox question Mike Excel Programming 8 May 5th 06 03:20 AM
Checkbox question Patrick Simonds Excel Programming 6 July 31st 05 05:49 PM
CheckBox question Frank Rudd via OfficeKB.com Excel Programming 2 July 1st 05 12:35 AM
CheckBox question Sheldon Excel Programming 6 January 25th 05 05:11 PM


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"