PDA

View Full Version : VBA Help: Date/Time Stamp functionality



knatebaker
02-03-2017, 11:33 AM
Hey all,

So, I've come up with this code, which lets me select a cell, hit the button, and then the selected cell produces the date/time stamp.

--------------------

Sub MyTimeStamp()

Dim DT

'
' MyTimeStamp Macro
'
' Keyboard Shortcut: Ctrl+t
'
DT = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")

ActiveCell.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm AM/PM"
ActiveCell.Value = DT

End Sub
-------------------

What I want it to do is produce that Date/Time Stamp to a specific cell without needing to select it, and the targeted cell would be based off of the current day. Here is what I have on my current spreadsheet:

18242 18243

So, what I want it to do, is I hit the button next to "Kevin" on the Dashboard tab, and it input a "X" or just a date/time stamp into the cell under the column for Kevin by the calendar date it was hit.

Help please!?
Nate

mancubus
02-03-2017, 01:43 PM
welcome to the forum.
please take time to read the forum rules.

post your code using code tags (see my signature).

upload your workbook so that members here can post a solution using the original workboo(s)k and worksheet(s) (see my signature).
you may wish to alter company specific data.

knatebaker
02-06-2017, 07:34 AM
My bad, it looks like the tags were kindly added by mark007. Thanks!

I've uploaded the workbook. As a side note, what I want in the OP isn't strict. If there is another work around that would emulate this effect, any advise would be greatly appreciated.

mancubus
02-06-2017, 03:38 PM
insert a button (forms control) into sheet Dashboard and assign below macro to it.
check (or uncheck) the boxes then click the button.

a sample file based on your workbook is attached.



Sub vbax_58478_date_time_stamp_functionality()

Dim chk As CheckBox
Dim RowNum As Long, ColNum As Long

For Each chk In Worksheets("Dashboard").CheckBoxes
With chk
If .Value = 1 Then
RowNum = Worksheets("Tracking Summary").Columns(1).Find(Date).Row
ColNum = Worksheets("Tracking Summary").Rows(2).Find(.TopLeftCell.Offset(0, -1).Value).Column
Worksheets("Tracking Summary").Cells(RowNum, ColNum).Value = "X"
'or
'Worksheets("Tracking Summary").Cells(RowNum, ColNum).Value = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")
End If
End With
Next chk

End Sub

knatebaker
02-10-2017, 07:21 AM
Thank you so much!

mancubus
02-10-2017, 08:07 AM
you are welcome.
pls mark the thread as solved from Threadtools for future references.