View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default Help with Macro or VBA script - Insert current Time/Date for diffe

You could create a button - either a CommandButton on your sheet or a custom
toolbar button, and set it to run the following code:

Public Sub Button1.Click
ActiveCell.Value = Now()
ActiveCell.NumberFormat = "mm/dd/yy hh:mm"
End Sub

Then NumberFormat part is to make sure the time stamp shows as a date/time
and not as a numeric value, which would look strange - you could adjust the
format there it if you prefer it to be different.

P.S. in the current Excel world macros and VBA are really the same: the
macro recorder simply creates VBA code for you, and thus is easier for users
who do not know how to write code, but you can always edit the code or create
your own. A good way to get started is to record some macros as you do
various things and look at the resulting code - you can learn a lot this way.
But as you learn more VBA you will learn how you can write code that is more
efficient and more adaptable to different situations than you will get with
the macro recorder.

" wrote:

Hello,

I'm trying to work on a spreed sheet for tracking vendor calls and what
have you. I would like to make it easy for our workers to insert the
current date and time by means of a mouse click. Currently I have used
validation to give them dropdown lists for varying cell data and would
like something kinda like that for the date/time issue. I know of the
=NOW() function but the issue i have with, when wrapped with validation
at least) is that it needs to be recalculated which means they have to
click the drop down box, select the time and then reclick to post the
current date/time.

I'm sure I will need to use a Macro or VBA but I'm pretty green on both
these topics and would like some input on how I might accomplish said
task. It looks as if VBA is more advanced than a regular macro so I
assume VBA is the way to go.


Thanks ahead of time for all your input.

Mattchewie