Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Joe
 
Posts: n/a
Default Check box, then add current time to cell

I am pretty new to macros and just found out what they were and kind of how
they work. I am trying to make a check list that when the box is checked the
current time is inserted to a different cell. Any advice on how to do this
would be much appreciated.

Thanks,
--
Joe
  #2   Report Post  
Rowan
 
Posts: n/a
Default

Hi Joe

There are a few things to consider the first being do you use checkboxes
from the Forms Toolbar or from the Controls Toolbox. If you search
google groups you will probably find a lot of discussions on the pros
and cons of each, I won't go into it all here.

If you use Checkboxes from the Controls Toolbox you can double click on
each checkbox while in design mode which will take you to the click
event for that checkbox. You can then add code similar to this:

Private Sub CheckBox1_Click()
Me.Range("A5").Value = Format(Now(), "hh:mm:ss")
End Sub

You would have to have an individual event macro like this for each
checkbox. There are methods to use one event for multiple controls but
they can get quite complicated. One way is described he
http://j-walk.com/ss/excel/tips/tip44.htm

Alternately you could use checkboxes from the forms toolbar. You could
then right click each checkbox and assign the same macro to each. This
macro would sit in a standard code module and look something like this:

Sub CheckBoxes()
With Sheets("Sheet5")
Select Case Application.Caller
Case "Check Box 1"
.Range("A5").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 2"
.Range("A6").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 3"
.Range("A7").Value = Format(Now(), "hh:mm:ss")
'etc
End Select
End With
End Sub

Doing it this way though, I am not sure how you would check the status
of the checkbox i.e the Time would be set every time the checkbox is
clicked not just when it is clicked to add a check mark.

Anyway, I hope this helps
Rowan

Joe wrote:
I am pretty new to macros and just found out what they were and kind of how
they work. I am trying to make a check list that when the box is checked the
current time is inserted to a different cell. Any advice on how to do this
would be much appreciated.

Thanks,

  #3   Report Post  
Joe
 
Posts: n/a
Default

Thanks, I will try this tomorrow at work.
--
Joe


"Rowan" wrote:

Hi Joe

There are a few things to consider the first being do you use checkboxes
from the Forms Toolbar or from the Controls Toolbox. If you search
google groups you will probably find a lot of discussions on the pros
and cons of each, I won't go into it all here.

If you use Checkboxes from the Controls Toolbox you can double click on
each checkbox while in design mode which will take you to the click
event for that checkbox. You can then add code similar to this:

Private Sub CheckBox1_Click()
Me.Range("A5").Value = Format(Now(), "hh:mm:ss")
End Sub

You would have to have an individual event macro like this for each
checkbox. There are methods to use one event for multiple controls but
they can get quite complicated. One way is described he
http://j-walk.com/ss/excel/tips/tip44.htm

Alternately you could use checkboxes from the forms toolbar. You could
then right click each checkbox and assign the same macro to each. This
macro would sit in a standard code module and look something like this:

Sub CheckBoxes()
With Sheets("Sheet5")
Select Case Application.Caller
Case "Check Box 1"
.Range("A5").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 2"
.Range("A6").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 3"
.Range("A7").Value = Format(Now(), "hh:mm:ss")
'etc
End Select
End With
End Sub

Doing it this way though, I am not sure how you would check the status
of the checkbox i.e the Time would be set every time the checkbox is
clicked not just when it is clicked to add a check mark.

Anyway, I hope this helps
Rowan

Joe wrote:
I am pretty new to macros and just found out what they were and kind of how
they work. I am trying to make a check list that when the box is checked the
current time is inserted to a different cell. Any advice on how to do this
would be much appreciated.

Thanks,


  #4   Report Post  
Joe
 
Posts: n/a
Default

Rowan,

Thanks for the help, I assigned the same macro to each of the check boxes
and the time gets updated into the assigned cells, the only problem is that
the time updates when the boxes get unchecked too. I would like to make it
to where when the check boxes are unchecked that the time is erased out of
the cells.

Thanks again,
--
Joe


"Rowan" wrote:

Hi Joe

There are a few things to consider the first being do you use checkboxes
from the Forms Toolbar or from the Controls Toolbox. If you search
google groups you will probably find a lot of discussions on the pros
and cons of each, I won't go into it all here.

If you use Checkboxes from the Controls Toolbox you can double click on
each checkbox while in design mode which will take you to the click
event for that checkbox. You can then add code similar to this:

Private Sub CheckBox1_Click()
Me.Range("A5").Value = Format(Now(), "hh:mm:ss")
End Sub

You would have to have an individual event macro like this for each
checkbox. There are methods to use one event for multiple controls but
they can get quite complicated. One way is described he
http://j-walk.com/ss/excel/tips/tip44.htm

Alternately you could use checkboxes from the forms toolbar. You could
then right click each checkbox and assign the same macro to each. This
macro would sit in a standard code module and look something like this:

Sub CheckBoxes()
With Sheets("Sheet5")
Select Case Application.Caller
Case "Check Box 1"
.Range("A5").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 2"
.Range("A6").Value = Format(Now(), "hh:mm:ss")
Case "Check Box 3"
.Range("A7").Value = Format(Now(), "hh:mm:ss")
'etc
End Select
End With
End Sub

Doing it this way though, I am not sure how you would check the status
of the checkbox i.e the Time would be set every time the checkbox is
clicked not just when it is clicked to add a check mark.

Anyway, I hope this helps
Rowan

Joe wrote:
I am pretty new to macros and just found out what they were and kind of how
they work. I am trying to make a check list that when the box is checked the
current time is inserted to a different cell. Any advice on how to do this
would be much appreciated.

Thanks,


  #5   Report Post  
Rowan
 
Posts: n/a
Default

Hi Joe

If you right click each checkbox, select Format Control and add a cell
link you can then check the value of this cell which will be true if the
box is checked, otherwise false.

In this example I have linked each checkbox to a cell in column Z which
can then be hidden:

Sub CheckBoxes()
With Sheets("Sheet5")
Select Case Application.Caller
Case "Check Box 1"
If .Range("Z5").Value Then
.Range("A5").Value = Format(Now(), "hh:mm:ss")
End If
Case "Check Box 2"
If .Range("Z6").Value Then
.Range("A6").Value = Format(Now(), "hh:mm:ss")
End If
Case "Check Box 3"
If .Range("Z7").Value Then
.Range("A7").Value = Format(Now(), "hh:mm:ss")
End If
'etc
End Select
End With
End Sub

Hope this helps
Rowan

Joe wrote:
Rowan,

Thanks for the help, I assigned the same macro to each of the check boxes
and the time gets updated into the assigned cells, the only problem is that
the time updates when the boxes get unchecked too. I would like to make it
to where when the check boxes are unchecked that the time is erased out of
the cells.

Thanks again,



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Check box, then add current time to cell

Hey Joe,

This worked for me when I used the forms menu to create my check box. I
linked my checkbox to F4, and I placed the time in F5.

Sub CheckBox1_Click()

With ActiveSheet
If [F4].Value = True Then
With [F5]
.Value = Now
.NumberFormat = "mm/dd/yyyy h:mm:ss AM/PM"
End With
Else
With [F5]
.Value = Null
End With
End If

End With

End Sub

Hope this helps!

Stephanie

"Joe" wrote:

I am pretty new to macros and just found out what they were and kind of how
they work. I am trying to make a check list that when the box is checked the
current time is inserted to a different cell. Any advice on how to do this
would be much appreciated.

Thanks,
--
Joe

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
perform calculation only if current time is after 10 am julieskennels Excel Worksheet Functions 7 July 18th 05 08:07 PM
Show a time from one calculated cell as a decimal in another cell. KathyS Excel Worksheet Functions 1 January 20th 05 01:00 AM
#REF! with cell value check Shane White Excel Discussion (Misc queries) 0 January 3rd 05 05:29 PM
Current Cell Color mike47338 Excel Worksheet Functions 5 December 10th 04 06:45 PM
Combined date time cell to separate date & time components Mark Ada Excel Worksheet Functions 1 December 2nd 04 12:04 AM


All times are GMT +1. The time now is 09:13 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"