我需要根据2个条件找到一个值,只是该值的位置发生变化。
我有以下代码:
Function montomensual(clave As Integer, mes As String) As Double
Dim cell As Range
Set claves = Worksheets("Agotamiento").Range("C15:C500")
Select Case mes
Case "Enero"
For Each cell In claves
If clave = cell.Value Then
montomensual = cell.Offset(0, 12).Value
End If
Next cell
Case "Febrero"
For Each cell In claves
If clave = cell.Value Then
montomensual = cell.Offset(0, 16).Value
End If
Next cell
Case "Marzo"
For Each cell In claves
If clave = cell.Value Then
montomensual = cell.Offset(0, 20).Value
End If
Next cell
End Select
End Function
但是该函数返回#Value!
我不知道自己缺少什么,感谢所有帮助。