'How to to specify a word plus a date in a cell?
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 ("Test)" And
shows the current date.
Cell i2 should show "Test December 2021".
Error:
Run-time error '13': Type mismatch
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |