View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Create a New Workbook

It depends on what you put in that cell.

If you put a formula:
=now()-int(now())
or
=mod(now(),1)
this will change each time the worksheet is recalculated.

But if you put a value in that cell, it won't change (well, unless you change
it).

Are you sure you saw that in help?

kaykayIT wrote:

Thank you Dave for your help. If I return to current time in the cell
specified, will that time change when the sheet is recalculated? I need a
time that will never change but will always be the time that the worksheet
was created. I do not want the user to have to put in the current time as
his TIME IN or any changes to the TIME IN time. According to the help in
Excel VBA inserting the current time can change if the sheet is updated.

"Dave Peterson" wrote:

Are you looking to return the current time?

You can use VBA's builtin Time or Date:

Option Explicit
Sub testme01()

Dim justTime As Date
justTime = Time
MsgBox justTime

'or
Dim DateAndTime As Date
DateAndTime = Now
MsgBox DateAndTime

'or
Dim justDate As Date
justDate = Date
MsgBox justDate

End Sub



kaykayIT wrote:

I created a worksheet template but the problem is that a new workbook is not
created when the new worksheet is created. The purpose of a new workbook is
to get the creation date of the workbook for subtracting time out from time
in.(See Code Below)

Cells(30, 3).Value =
Format(Application.ActiveWorkbook.BuiltinDocumentP roperties("Creation Date"),
"h:mm am/pm")

How do I use VBA to create a new workbook and can I put an icon on the
desktop to run this code?


--

Dave Peterson


--

Dave Peterson