vba中的小技巧

字符串连接:

idate = Now

i = Year(idate)
ii = Month(idate)
iii = Day(idate)
iiii = Hour(idate)

LocalDate = b & "     " & i & "年" & ii & "月" & iii & "日" & "      " & iiii & "时"
LocalDay = i & "年" & ii & "月" & iii & "日"

字符串拼接:

    ActiveWorkbook.SaveAs .....
        "C:\Documents and Settings\10059329\新建文件夹\文件名" & LocalDay & ".xls",

&:强制拼接

+:对字符串连接,对数字进行加法运算

日期:

"d"为日,“m”为月,“yyyy”为年。

idate = DateAdd("d", i, dt1) 增加i天

idate = DateAdd("d", -i, dt1)减少i天

posted @ 2012-12-29 14:35  笑看天下  阅读(214)  评论(0编辑  收藏  举报