mardi 8 juin 2021

How to add today's date if cell is empty, and if not skip to next column?

Im a complete VBA noob and im trying to do what seems to be a simple thing.

The purpose of my code is to make a button where it checks to see if the cell is not empty, it should offset to the next column and if it is empty, then it should add todays date.

Here is the code I wrote:

Private Sub New_Date_Click()
ActiveSheet.Range("E1").Select
If Not IsEmpty(ActiveCell.Value) Then
    ActiveCell.Offset(0,1)

Else
ActiveCell.Value = Date
End Sub

It gives me an error message that an Equal sign is missing on row 4 where the offset is.

What My sheet looks like

Aucun commentaire:

Enregistrer un commentaire