+ Reply to Thread
Results 1 to 5 of 5

Check box, then add current time to cell

  1. #1
    Joe
    Guest

    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. #2
    Rowan
    Guest

    Re: Check box, then add current time to cell

    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 here:
    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. #3
    Joe
    Guest

    Re: Check box, then add current time to cell

    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 here:
    > 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. #4
    Joe
    Guest

    Re: Check box, then add current time to cell

    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 here:
    > 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. #5
    Rowan
    Guest

    Re: Check box, then add current time to cell

    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,


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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