F
floydbates
All:
First let me say that I am a programming neophyte, but I still need
your assistance. I have tried to do my homework; however, I am
certain that I am missing something.
My goal is to:
1. Read a range into a multi-dimensional array, 4 columns by 500
rows. Each column is or could be an array within the multi-
dimension array.
2. Modify input data such that the original array is different than
the current.
3. Add the original array to the modified array.
4. Repeat this addition of previous array and current array for a
fixed number of iterations.
5. Write the cumulative summation array to a worksheet.
My challenges are:
1. How to create and test a multi-dimensional array.
2. How to add two multi-dimensional arrays.
3. How to write a multi-dimensional array to a worksheet.
Any guidance would be greatly appreciated.
Here is what I have so far:
Sub BuildCompositeProductionProfiles()
Dim NumberOfPatterns As Integer
Dim NumberOfForecastedMonths As Integer
Dim OilRateArray As Variant
Dim WaterRateArray As Variant
Dim GasRateArray As Variant
Dim InjWaterArray As Variant
Dim AllStreamsArray() As Variant
'Initialize counters
NumberOfPatterns = 75
NumberOfForecastedMonths = 500
'Call routine to build multi-dimensional array
Call BuildAllStreams(AllStreamsArray, NumberOfForecastedMonths,
OilRateArray, WaterRateArray, GasRateArray, InjWaterArray)
End Sub
Sub BuildAllStreams(AllStreamsArray, NumberOfForecastedMonths As
Integer, OilRateArray, WaterRateArray, GasRateArray, InjWaterArray)
Dim AllStreamsRange As Range
With Worksheets("ThruPut")
Set AllStreamsRange = .Range("AO8:AR" &
NumberOfForecastedMonths + 7)
End With
AllStreamsArray = Application.Transpose(AllStreamsRange) [Error #1]
ReDim Preserve AllStreamsArray(1 To NumberOfForecastedMonths)
[Error #2]
[Error #3]
'Dim i As Integer
'For i = LBound(AllStreamsArray) To UBound(AllStreamsArray)
'Debug.Print AllStreamsArray(OilRateArray(i), WaterRateArray(i),
GasRateArray(i), InjWaterArray(i)), i
'Next i
End Sub
Floyd
First let me say that I am a programming neophyte, but I still need
your assistance. I have tried to do my homework; however, I am
certain that I am missing something.
My goal is to:
1. Read a range into a multi-dimensional array, 4 columns by 500
rows. Each column is or could be an array within the multi-
dimension array.
2. Modify input data such that the original array is different than
the current.
3. Add the original array to the modified array.
4. Repeat this addition of previous array and current array for a
fixed number of iterations.
5. Write the cumulative summation array to a worksheet.
My challenges are:
1. How to create and test a multi-dimensional array.
2. How to add two multi-dimensional arrays.
3. How to write a multi-dimensional array to a worksheet.
Any guidance would be greatly appreciated.
Here is what I have so far:
Sub BuildCompositeProductionProfiles()
Dim NumberOfPatterns As Integer
Dim NumberOfForecastedMonths As Integer
Dim OilRateArray As Variant
Dim WaterRateArray As Variant
Dim GasRateArray As Variant
Dim InjWaterArray As Variant
Dim AllStreamsArray() As Variant
'Initialize counters
NumberOfPatterns = 75
NumberOfForecastedMonths = 500
'Call routine to build multi-dimensional array
Call BuildAllStreams(AllStreamsArray, NumberOfForecastedMonths,
OilRateArray, WaterRateArray, GasRateArray, InjWaterArray)
End Sub
Sub BuildAllStreams(AllStreamsArray, NumberOfForecastedMonths As
Integer, OilRateArray, WaterRateArray, GasRateArray, InjWaterArray)
Dim AllStreamsRange As Range
With Worksheets("ThruPut")
Set AllStreamsRange = .Range("AO8:AR" &
NumberOfForecastedMonths + 7)
End With
AllStreamsArray = Application.Transpose(AllStreamsRange) [Error #1]
ReDim Preserve AllStreamsArray(1 To NumberOfForecastedMonths)
[Error #2]
[Error #3]
'Dim i As Integer
'For i = LBound(AllStreamsArray) To UBound(AllStreamsArray)
'Debug.Print AllStreamsArray(OilRateArray(i), WaterRateArray(i),
GasRateArray(i), InjWaterArray(i)), i
'Next i
End Sub
Floyd