SOLVED

Assign current cell based on value next to it

Brass Contributor

Give 2 adjacent cells i.e. A1 and A2.

How do I make a formula in A1 based off A2.

Goal: I'd like a user to be able to enter their initials in A2 and then auto date it in A1

 

3 Replies

@rodsan724 

Do you want A1 to record the date when A2 is first filled, or whenever the value of A2 is edited?

whenever A2 is edited.
best response confirmed by rodsan724 (Brass Contributor)
Solution

@rodsan724 

Thanks.

Right-click the sheet tab.

Select 'View Code' from the context menu.

Copy the code listed below into the worksheet module.

Switch back to Excel.

Save the workbook as a macro-enabled workbook (*.xlsm).

Make sure that you allow macros when you open the workbook.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("A2"), Target) Is Nothing Then
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        If Range("A2").Value = "" Then
            Range("A1").ClearContents
        Else
            Range("A1").Value = Date ' or Now to include the time
        End If
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub