I'm writing a VBA macro in Excel that analyzes data from the spreadsheet and sends an email. In this macro, I have to attach the date formatted as "MM/dd" but the output is in the format of "MM-dd". So the question is, why is my slash getting replaced with a dash?
For simplicity, I have reduced the code to this example, and verified the problem exists with this example as well...
Private Sub Test()
Dim Yesterday As Date: Yesterday = DateAdd("d", -1, Now)
MsgBox Format(Yesterday, "MM/dd")
End Sub
When run, the message box shows "12-15" instead of "12/15" as expected.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…