elotromateo
New Member
- Joined
- May 19, 2010
- Messages
- 42
I keep getting a type mismatch error when I try to round "z(1,1)". I don't understand this as the value is a numeric expression, even if it is a Variant type. Even if I get rid of the round, I still can't put it in a message box, despite asking for only the one value. I am completely at a loss for what to do here. I've tried converting the value and assigning it to a different variable, but that spit out the type mismatch error as well.
Any thoughts?
Any thoughts?
Code:
Option Base 1
Sub test()
Dim T As Double, RH As Double, z(1, 1) As Variant
Dim ArrayT(1, 1 To 4) As Variant
Dim ArrayV(1 To 4, 1 To 4) As Variant
Dim ArrayRH(1 To 4, 1) As Variant
Dim ArrayMult(1 To 4, 1) As Variant
Dim i As Integer, j As Integer
T = 85
RH = 60
With Sheets("Sheet2")
For i = 1 To 4
For j = 1 To 4
ArrayV(i, j) = .Cells(i, j)
Next
Next
End With
If T >= 80 Then
For i = 1 To 4
ArrayT(1, i) = (T) ^ (i - 1)
Next
For j = 1 To 4
ArrayRH(j, 1) = (RH) ^ (j - 1)
Next
For i = 1 To 4
ArrayMult(i, 1) = Application.MMult(ArrayV, ArrayRH)(i, 1)
Next
z(1, 1) = Application.MMult(ArrayT, ArrayMult)
z(1, 1) = Round(z(1, 1), 1)
Else
z(1, 1) = T
End If
MsgBox z(1, 1)
End Sub