Current time by clicking comm button in excel

Closed
geoganesh_80 Posts 1 Registration date Monday July 12, 2010 Status Member Last seen July 12, 2010 - Jul 12, 2010 at 05:05 AM
venkat1926 Posts 1864 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 26, 2010 at 03:48 AM
Hello,


how to get the current time by clicking command button for any active cell
Related:

3 replies

venkat1926 Posts 1864 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 810
Jul 12, 2010 at 05:58 AM
bring a "comman button" from the control toolbar and place it somewhere in the sheet.
right click the sheet tab and click view code. There you copy this code


Private Sub CommandButton1_Click()
ActiveCell = Now()
ActiveCell.NumberFormat = "hh:mm:ss"
End Sub
14
whr z cmmnd button in ctrl toolbar??i hv to wrk this thing in excel sheet & thr z no control toolbar thr.....
I wnt to display current time whn a cell of xcel sheet is clicked..
0
venkat1926 Posts 1864 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 810
Aug 20, 2010 at 05:44 AM
of course you can bring the button from the form toolbar. view-toolbars-form

alternatively do this
right click sheet tab and click view code.
there you copy this event code
AFTER SELECTING A CELL YOU HAVE TO RIGHT CLICK THE CELL


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) 
Cancel = True 
Target = Now() 
Target.NumberFormat = "hh:mm:ss" 
End Sub 
1
Terriable at this
Aug 26, 2010 at 02:45 AM
how to isolate it to certain cells.
0
venkat1926 Posts 1864 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 810
Aug 26, 2010 at 03:48 AM
if the relevant cells you want to have this result is only one paritcualr row(s) or column(s). if it is in a few particular cells in a row or column how many are there.

you can use a statement that if the selected cell is not the relevant cell then nothing should happen(that is exit sub)

so clarify this point.
0