Answered by:
VBA Excel Arrays; declaration, assignment and initiation

Hello
Can anybody help me with that piece of code?
I would like to get the following array: (N2, 126.2, 0.313), but a run time error is popups ("subscript out of range").
Thanks in advanced,
Avi
Option Explicit Option Base 1 Private x As Variant Sub Viscosity_Calc() Dim A(1, 1, 1) As Variant Dim Gas_matrix As Variant Dim Gas_type As Variant Dim Critical_Temp As Variant Dim Critical_Density As Variant Gas_type = Array("N2", "Ar", "O2", "Air") 'Gas List Critical_Temp = Array(126.2, 150.6, 154.5, 132.5) '[K] Temp. at critical point Critical_Density = Array(0.313, 0.531, 0.436, 0.316) '[g/ml] Density at critical point Gas_matrix = Array(Gas_type, Critical_Temp, Critical_Density) A(1, 1, 1) = Array(Gas_matrix((1), (1), (1))) End Sub
Avi Reches
 Moved by Mark LiulxfModerator Friday, April 27, 2012 3:15 AM (From:Visual Basic Language)
Question
Answers

On Thu, 26 Apr 2012 16:21:08 +0000, Reches wrote:>>>Hello>>Can anybody help me with that piece of code?>>I would like to get the following array: (N2, 126.2, 0.313), but a run time error is popups ("subscript out of range").>>Thanks in advanced,>>Avi Option Explicit>Option Base 1>Private x As Variant>Sub Viscosity_Calc()>>Dim A(1, 1, 1) As Variant>Dim Gas_matrix As Variant>Dim Gas_type As Variant>Dim Critical_Temp As Variant>Dim Critical_Density As Variant>>Gas_type = Array("N2", "Ar", "O2", "Air") 'Gas List>>Critical_Temp = Array(126.2, 150.6, 154.5, 132.5) '[K] Temp. at critical point>>Critical_Density = Array(0.313, 0.531, 0.436, 0.316) '[g/ml] Density at critical point>>Gas_matrix = Array(Gas_type, Critical_Temp, Critical_Density)>>>A(1, 1, 1) = Array(Gas_matrix((1), (1), (1)))>End Sub>>>>>>>Avi RechesA(1, 1, 1) = Array(Gas_matrix(1)(1), Gas_matrix(1)(1), Gas_matrix(1)(1))
Ron Marked as answer by Reches Friday, April 27, 2012 10:16 PM
All replies

try asking in the vba forum:
http://social.msdn.microsoft.com/forums/en/isvvba/threads
thanks for any help

On Thu, 26 Apr 2012 16:21:08 +0000, Reches wrote:>>>Hello>>Can anybody help me with that piece of code?>>I would like to get the following array: (N2, 126.2, 0.313), but a run time error is popups ("subscript out of range").>>Thanks in advanced,>>Avi Option Explicit>Option Base 1>Private x As Variant>Sub Viscosity_Calc()>>Dim A(1, 1, 1) As Variant>Dim Gas_matrix As Variant>Dim Gas_type As Variant>Dim Critical_Temp As Variant>Dim Critical_Density As Variant>>Gas_type = Array("N2", "Ar", "O2", "Air") 'Gas List>>Critical_Temp = Array(126.2, 150.6, 154.5, 132.5) '[K] Temp. at critical point>>Critical_Density = Array(0.313, 0.531, 0.436, 0.316) '[g/ml] Density at critical point>>Gas_matrix = Array(Gas_type, Critical_Temp, Critical_Density)>>>A(1, 1, 1) = Array(Gas_matrix((1), (1), (1)))>End Sub>>>>>>>Avi RechesA(1, 1, 1) = Array(Gas_matrix(1)(1), Gas_matrix(1)(1), Gas_matrix(1)(1))
Ron Marked as answer by Reches Friday, April 27, 2012 10:16 PM

