to run a command in a cell

  • Thread starter Thread starter Steven Van Laethem
  • Start date Start date
S

Steven Van Laethem

Hello,

I want to run a command --> =Now()
in a cell.

I want it configured as a button ( in a cell) so when i press that
button/cell that automaticayly it takes the system date and tim.

Who can help me ?
 
Set the Security level to low/medium in (Tools|Macro|Security). From workbook
launch VBE using short-key Alt+F11. From menu 'Insert' a module and paste the
below code. Save. Get back to Workbook.

Sub Macro1()
Range("A1") = Now
End Sub

--From Toolbars>DrawingToolbar>AutoShapes>Basic Shapes select any shape you
like. say ("Bevel") and place that in your worksheet.

--Right click the shape>Assign Macro> and select the macro to be assigned

--Now try Button click


If this post helps click Yes
 
Did all but doesn't work. I use Excel 2007 is your solution also for this
version ?

The command to have the system date&time is =now()

must it be the same your code ?
 
Hi again ;-)

it does work but it changes the field A1 but i want it to a cell that i want.
I click f.e. on A47 and click the button and then date&time appears in A47
 
Check out this


Sub Macro1()
Range("A1") = Now
End Sub

=NOW() is a formula. The above macro will insert the current date and time
to cell A1. If you are looking to insert a formula try

Sub Macro1()
Range("A1") = "=NOW()"
End Sub


If this post helps click Yes
 
That is working ! You are great.

Any chance that i can introduce that in a single cell

So i click A47 and that the date&time comes automatically
 
Back
Top