New user coming from Excel.
It’s strange but the code below works sometimes, and other times it doesn’t.It’s from Excel VBA. On error, it’s telling me ‘Basic runtime error. ‘13’ Data type mismatch’ and highlights the row with ‘For Each Mycell in Selection’. Can this code be edited slightly to fix it?
Sub TodaysDate()
For Each Mycell In Selection
Mycell.Activate
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next Mycell
End Sub
(Slightly edited by @Lupp to get two additional lines into the code range.)