I want to specify a word plus a date in a cell.
Sub CurrentTestCell()
With Range("i2")
.Value = ("Test") And Date
.NumberFormat = "mmmm yyyy"
End With
End Sub
The code without the ("Test)" And
works and shows the current date.
The field should show i2 "Test Dezember 2021
"
Error:
Run-time error '13': Type mismatch
CodePudding user response:
Date format will not work on text data. You need format function for dates. Try-
Sub CurrentTestCell()
With Range("I2")
.Value = "Test " & Format(Date, "mmmm yyyy")
End With
End Sub