VBA - 插入maxIF公式

时间:2015-03-02 16:39:30

标签: vba max formula

我有几张数据表,我需要根据其他列中的条件找到最高和最低日期。 我已为这些其他列定义了ranged,并希望在VBA中插入公式,但我一直收到438错误“对象不支持此属性或方法。

有关错误的任何线索,下面是我的代码的提取 - 当我调试它时,问题是公式。

Dim emp As Range
Set emp = Range("R5", ActiveCell.End(xlDown))
Dim epidno As Range
Set epidno = Range("B5").End(xlDown)
Dim jobtype As Range
Set jobtype = Range("D5", Selection.End(xlDown))
Dim jobdate As Range
Set jobdate = Range("J5", Selection.End(xlDown))

Dim datecell As Range
For Each datecell In Range("R5", ActiveCell.End(xlDown).End(xlDown).End(xlUp))
datecell.Offset(0, 1).Formula.Cell.FormulaR1C1 = "=MIN(IF(" + jobtype.adress + " =""TECHNICIAN"",IF(" + epidno.adress + "=RC[-1]," + jobdate.adress + ",""""),""""))"

1 个答案:

答案 0 :(得分:1)

"=MIN(IF(" + jobtype.address + " =""TECHNICIAN"",IF(" + epidno.address + "=RC[-1]," + jobdate.address + ",""""),""""))"

范围没有.adress属性,有.Address属性(2 D' s,2 S' s。)