hide NOW date if correspoding cell in row is empty

hi all

i'm building a table with a column of NOW fuction to automatically enter current date and time 

let's assume cell B1 is a blank cell with no value and cell C1 is a date formatted cell ,

what i want is : whenever i enter any text or number or formula in cell B1 , then cell C1 will display date and time of B1 entry

and if B1 is still blank C1 will display nothing

May 26th, 2015 6:59am

You need a bit of VBA code for that.

Right-click the sheet tab.

Select 'View Code' from the context menu.

Copy the following code into the worksheet module that appears:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cel As Range
    If Not Intersect(Range("B:B"), Target) Is Nothing Then
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        For Each cel In Intersect(Range("B:B"), Target)
            If cel.Value = "" Then
                cel.Offset(0, 1).ClearContents
            Else
                cel.Offset(0, 1).Value = Now
            End If
        Next cel
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub

Close the Visual Basic Editor.

Save the workbook in a format that supports macros (.xlsm, .xlsb or .xls, but not .xlsx).

You'll have to allow macros when you open the workbook.

Free Windows Admin Tool Kit Click here and download it now
May 26th, 2015 8:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics