+ Reply to Thread
Results 1 to 2 of 2

Disabling a Time Function

Hybrid View

  1. #1
    Registered User
    Join Date
    12-15-2009
    Location
    Moros
    MS-Off Ver
    Excel 2003
    Posts
    7

    Disabling a Time Function

    I searched the forum and couldn't find an answer to this.

    I'm creating a system that will allow staff to scan their work-card to show when they arrived. What I need is a cell that dynamically gets the current system time and enters it into a cell. Once this time value is entered I would like the cell to become just a value i.e. no function.

    Here's what I have.

    I have a cell with the formula -
    =IF(ISBLANK(D9),"FAIL",showTime())
    The showTime function is in the Module

    Function showTime() As Variant
    showTime=Now
    End Function
    This works correctly on the first usage but then the value gets updated every time the sheet opens and sometimes when I'm editing other Functions.

    So is there a way of making a function run once, or disabling a function, preferably I would like to change the cell contents to a value.

    Any help would be appreciated.

    Keill
    Last edited by KeillRandor; 12-16-2009 at 06:33 AM. Reason: Formatting Post

  2. #2
    Registered User
    Join Date
    12-15-2009
    Location
    Moros
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Disabling a Time Function

    My new plan is the following -
    I have a new Sub called output that I pass the Cell reference that calls the sub i.e For the cell A1 it would contain the formula
    =output(A1)
    What I want output to do is check if the cell calling the sub contains a function - which it has to - if so use the Cells.ClearContents method to erase the formula and the Cells.Value to insert a value.

    Here's what output looks like -
    Sub output(cellReference As Range)
    Dim cellcolumn, cellrow cellcolumn = cellReference.Cells.Column cellrow = cellReference.Cells.Row IF(cellreference.HasFormula) Then
    'THIS IS WHERE THE PROBLEM IS 'I'M NOT SURE IF THE SYNTAX IS CORRECT cellReference.Cells.ClearContents cellReference.Cells.Value = Now 'THE ABOVE DID NOT WORK 'SO I TRIED Worksheet("Sheet1").Activate Cells(cellrow,cellcolumn).ClearContents Cells(cellrow,cellcolumn).Value = Now
    END IF
    END SUB
    It appears as though I can access the properties of the Cells class but can't use the modifiers.

    I tried
    Worksheet("Sheet1").Activate
    Cells(10,10).Value = 666
    as a test but nothing happened.

    So my question is this - is there anything else I should be doing?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1