我编程的简单VBA功能产生#VALUE!在Excel中使用时出错

时间:2017-11-09 13:08:21

标签: excel vba function

该函数被设计为接收输入 - 变量pg - 位于电子表格的单元格中,遍历数据行以查看第1列中的哪一行与变量pg匹配。找到匹配后,它会遍历列以查看哪些列具有" VRP23"或者" VRP24"在第一行。找到它后,它会获取匹配行/列的编号并执行" step1"修改。问题是,在电子表格中出现了错误#VALUE!,我不知道为什么会这样。

Function getECONpgdimscore1(pg As String) As Double

Dim row As Integer
row = 2

Dim c As Integer
c = 1
Dim econ As Double
econ = 0

Dim x As Integer
Dim NumRows As Integer
NumRows = Range("A2", Range("A2").End(xlDown)).rows.count
Cells(row, 1).Select

For x = 1 To NumRows
    If Cells(row, 1).Value = pg Then
        Do While c < 48
            Cells(row, 7 + c).Select
            If Cells(1, 7 + c).Value = ("VRP23" Or "VRP24") Then
                econ = econ + step1(Cells(1, 7 + c), Cells(row, 7 + c))
            End If
            c = c + 1
        Loop
    End If
    row = row + 1
Next x


getECONpgdimscore1 = (econ / 100) * 2.5

End Function

0 个答案:

没有答案