使用宏将单元格添加到单元格

时间:2013-09-30 10:31:31

标签: excel excel-vba excel-2010 vba

Dim dflrow As Integer

    ActiveWorkbook.Sheets("ElecTM").Range("I1048576").Select

    dflrow = Selection.End(xlUp).Row

'        ActiveWorkbook.Sheets("ElecTM").Range("AG" & dflrow & ":" & "AJ" & dflrow).Select

    ActiveWorkbook.Sheets("ElecTM").Range("AG6").Formula = "=CONCATENATE(Year(I6),"w",WeekNum(I6))"

    Selection.FillDown

这里我收到一条错误,说第五行有语法错误。我试过'.value'而不是'.Formula'。但这没有帮助。

2 个答案:

答案 0 :(得分:0)

"w"

中缺少双引号
ActiveWorkbook.Sheets("ElecTM").Range("AG6").Formula = _
"=CONCATENATE(Year(I6),""w"",WeekNum(I6))"

如果在"

之间使用,则必须使用额外"填充""

编辑:如有疑问,请录制宏;)

答案 1 :(得分:0)

w应该是双引号

ActiveWorkbook.Sheets("ElecTM").Range("AG6").Formula = "=CONCATENATE(Year(I6),""w"",WeekNum(I6))"