不可能写
STRINGA = "NamewordStuff" & Format(Date, "YYYY-MM-DD") & "-" & Hours(Now) & _
If Minute(Now)<10 then
"0" & Minute(Now)
Else
Minute(Now)
End If _
& ".xlsm"
我认为怎样才能以最优雅的方式做到这一点?
答案1
您可以使用Iif
:
STRINGA = "NamewordStuff" & Format(Date, "YYYY-MM-DD") & "-" & Hours(Now) & _
Iif(Minute(Now)<10, "0" & Minute(Now), Minute(Now)) & ".xlsm"
答案2
或者格式化数字:
STRINGA = "NamewordStuff" & Format(Date, "YYYY-MM-DD") & "-" & Hours(Now) & _
Format(Minute(Now),"00") & "xlsm"