0

有人可以帮我修复子中的公式吗?我需要通过变量将日期输入其中,但它总是给我一个错误“13”数据类型

我说的是位:

Cells(5, field).FormulaLocal = "=SUMMEWENNS(Rawdata!K2:K3446;Rawdata!I2:I3446;""bezahlt"";Rawdata!A2:A3446;" >= " & weekstart & "";Rawdata!A2:A3446;" <= " & weekend & "")"

除了那个公式之外的子工作......

Sub get_cal_weeks()
    Dim weeks As Integer, i As Integer, col As String, weekstart As Date, weekend As Date, calweeks() As Variant
    'start column is D
    col = "D"
    'get amount of weeks
    weeks = countcalweeks()
    'populate array calweeks
    calweeks = fillcalweeks(weeks)
    For i = 0 To weeks
        field = i + i + 4
        weekstart = calweeks(i, 0)
        weekend = calweeks(i, 1)
        Cells(5, field).FormulaLocal = "=SUMMEWENNS(Rawdata!K2:K3446;Rawdata!I2:I3446;""bezahlt"";Rawdata!A2:A3446;" >= " & weekstart & "";Rawdata!A2:A3446;" <= " & weekend & "")"

    Next
End Sub

谢谢

4

1 回答 1

0

我建议您转换为 long (如果您需要时间,也可以转换为 double )

Cells(5, field).FormulaLocal = "=SUMMEWENNS(Rawdata!K2:K3446;Rawdata!I2:I3446;""bezahlt"";Rawdata!A2:A3446;"">=" & CLng(weekstart) & """;Rawdata!A2:A3446;""<=" & CLng(weekend) & """)"
于 2013-06-07T10:27:14.403 回答