【发布时间】:2022-02-04 00:57:46
【问题描述】:
Sub test1()
MonthYear = MonthName(Right(2009, 2)) & " " & Left(2009, 2) 'locals window show "September 20"
Range("A1").Value = MonthYear '20-Sep is shown in cell A1 where the formula box is 20-09-2022
Range("A1").Value = "'" & MonthYear '---> my solution for the time being
End Sub
我想要的是在单元格 A1 中显示 September 20(就像在本地窗口中一样),作为文本而不是日期。
到目前为止我已经尝试过:
Sub test2()
MonthYear = "01-" & MonthName(Right(2009, 2)) & "-20" & Left(2009, 2) 'locals window show "01-September-2020"
Range("A1").Value = MonthYear '01-Sep-20 is shown in cell A1 where the formula box is 01-09-2020
Range("A2").Value = Format(MonthYear, "mmmm yy") 'AGAIN, 20-Sep is shown in cell A1 where the formula box is 20-09-2022
Range("A1").NumberFormat = "mmmm yy" 'another solution for the time being
End Sub
我的问题:
我该如何编写代码,以便将结果作为文本直接放入单元格中 September 20 ?
任何形式的帮助都将不胜感激。
提前谢谢你????
【问题讨论】: