Now-time Changes In All Cells

  • Hi!


    I have a simple macro that puts the function

    Code
    now()

    into the currently selected cell. Next time when I select another cell and put in the same function the now-time in the first cell changes to the new time. It seems like I can only have one now-time in the book. Is there a workaround for this? I like to put i now-time into one cell, while previous now-inputs remains.


    Cheers!


    /Horpe

  • Re: Now-time Changes In All Cells


    Hi


    if you wish to have the value rather than the variable each time the NOW function is entered you could include

    Code
    selection.Copy
        selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False


    after the VB which creates the function


    HTH


    Robert

  • Re: Now-time Changes In All Cells


    You could also not use NOW() and use date/time vba functions instead...


    Code
    Public Sub test()
    
    
    ActiveCell.Value = Date
    ActiveCell.Offset(1, 0).Value = Time
    
    
    End Sub


    This puts a value into the cell instead of a function.


    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Now-time Changes In All Cells


    My belated 2 cents worth.


    This will give you date and time in the cell


    Code
    Sub AddDate()
    Dim mydate As Date
    
    
    mydate = Now()
    Range("A1").Value = mydate
         
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!