![]() |
Inserting static times into cells using command buttons
Does anyone know how to do the above? Or have a piece of visual basic code
that i could adapt to do this? |
Inserting static times into cells using command buttons
The first macro create the button:
Sub Macro1() ActiveSheet.Buttons.Add(369.75, 65.25, 44.25, 22.5).Select Selection.OnAction = "staticc" End Sub The second macro puts the time into a cell: Sub staticc() Range("A1").Value = Time End Sub -- Gary's Student "rossmac2" wrote: Does anyone know how to do the above? Or have a piece of visual basic code that i could adapt to do this? |
Inserting static times into cells using command buttons
rossmac2 wrote: Does anyone know how to do the above? Or have a piece of visual basic code that i could adapt to do this? Where are the button? On plan or in a Form? Somehow or other try: Private Sub CommandButton1_Click() Range("A1").Value = Time End Sub Cheers, |
Inserting static times into cells using command buttons
I'll assume you know nothing about macro's so forgive me if this is too simple.
Open your workbook, then press Alt+F11, which opens the VBA editor Go to Insert, Module In the code window that appears paste this code: Sub AddTime() ActiveCell = Now() End Sub Go back to Excel From the "Forms" Toolbar, create a Command Button When Excel asks you what macro to run with this button, choose "AddTime" Select the cell you want the time in and Click the button -- Charles Chickering "A good example is twice the value of good advice." "rossmac2" wrote: Does anyone know how to do the above? Or have a piece of visual basic code that i could adapt to do this? |
All times are GMT +1. The time now is 12:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com