|
楼主 |
发表于 2013-11-8 14:26
|
显示全部楼层
那么的帅 发表于 2013-11-8 12:21
出现提示:运行时错误“242”
要求对像
整个代码如下:
Sub 合并计算()
'
' 合并计算 Macro
'
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row.Select
Selection.Consolidate Sources:="'月份 (10)'!C6:C10", _
Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False
ActiveWindow.SmallScroll Down:=6
Ro = [a65536].End(xlUp).Row
Ro1 = [a65536].End(xlUp).End(xlUp).Row
Range("D" & Ro).FormulaR1C1 = "=R3C"
Range("D" & Ro1 & ":D" & Ro).FillUp
Range("E" & Ro).FormulaR1C1 = "=VLOOKUP(RC[-4],单价!C[-3]:C[2],6,FALSE)"
Range("E" & Ro1 & ":E" & Ro).FillUp
Range("F" & Ro).FormulaR1C1 = "=VLOOKUP(RC[-5],单价!C[-4]:C[2],7,FALSE)"
Range("F" & Ro1 & ":F" & Ro).FillUp
Range("H" & Ro).FormulaR1C1 = "=SUMIF('月份 (10)'!C[-2],RC[-7],'月份 (10)'!C[2])"
Range("H" & Ro1 & ":H" & Ro).FillUp
Range("I" & Ro).FormulaR1C1 = "=VLOOKUP(RC[-8],'月份 (10)'!C[-3]:C,4,FALSE)"
Range("I" & Ro1 & ":I" & Ro).FillUp
Range("J" & Ro).FormulaR1C1 = "=VLOOKUP(RC[-9],'月份 (10)'!C[-4]:C[1],6,FALSE)/1.17"
Range("J" & Ro1 & ":J" & Ro).FillUp
Range("E" & Ro1 - 1).Select
Selection.ClearContents
Range("D" & Ro1 - 1).Select
Selection.ClearContents
Range("C" & Ro1 - 1).Select
Selection.ClearContents
Selection.Font.Bold = True
Selection.Font.Color = -4165632
Selection.NumberFormatLocal = "0.00_);[红色](0.00)"
Selection.HorizontalAlignment = xlCenter
Range("B" & Ro1 - 1).Select
Selection.ClearContents
Selection.Font.Bold = True
Selection.Font.Color = -4165632
Selection.HorizontalAlignment = xlCenter
Range("A" & Ro1 - 1).Select
ActiveCell.FormulaR1C1 = "10月份"
Selection.Font.Bold = True
Selection.Font.Color = -4165632
Selection.HorizontalAlignment = xlCenter
End Sub |
|