E
ExcelMonkey
I have a routine in ExcelVBA which creates a 2D array which is quite large.
It generates 1,000,000 million random numbers over a period of years (10). I
want to export each years worth of data upon generating the last random
number in each year.
I want to export to an Access File. I am new to access and have never
really used it before. So when finished, the Access File will have the full
2D array in it expressing my million data points over 10 years. Assuming it
will have to happen as follows:
1) Create Access File
2) Generate a years worth of random numbers in Excel/VBA
3) Export years worth of random numbers from Array in Excel/VBA
4) Come back to Excel and generate next years of random numbers
5) When finished, save Access file
How do I do this?
My Excel/VBA code looks as follows:
Sub PopulateArrayAndExporttoAccess()
Dim CurrentYear As Double
Dim CurrentNumber As Double
Dim BigArray As Variant
Dim LastNum As Double
Dim LastYear As Double
Application.ScreenUpdating = False
ReDim BigArray(1 To 1000000)
LastNum = UBound(BigArray)
LastYear = 10
For CurrentYear = 1 To LastYear
For CurrentNumber = 1 To LastNum
BigArray(CurrentNumber) = Rnd()
Application.StatusBar = "Creating random numbers: " &
Round((CurrentNumber / (LastNum * LastYear)) * 100, 2) & "%"
Next
'Export the full Array to Access
'Put export code here......
Application.StatusBar = "Exporting to Access."
Next
Application.StatusBar = ""
End Sub
Thanks
EM
It generates 1,000,000 million random numbers over a period of years (10). I
want to export each years worth of data upon generating the last random
number in each year.
I want to export to an Access File. I am new to access and have never
really used it before. So when finished, the Access File will have the full
2D array in it expressing my million data points over 10 years. Assuming it
will have to happen as follows:
1) Create Access File
2) Generate a years worth of random numbers in Excel/VBA
3) Export years worth of random numbers from Array in Excel/VBA
4) Come back to Excel and generate next years of random numbers
5) When finished, save Access file
How do I do this?
My Excel/VBA code looks as follows:
Sub PopulateArrayAndExporttoAccess()
Dim CurrentYear As Double
Dim CurrentNumber As Double
Dim BigArray As Variant
Dim LastNum As Double
Dim LastYear As Double
Application.ScreenUpdating = False
ReDim BigArray(1 To 1000000)
LastNum = UBound(BigArray)
LastYear = 10
For CurrentYear = 1 To LastYear
For CurrentNumber = 1 To LastNum
BigArray(CurrentNumber) = Rnd()
Application.StatusBar = "Creating random numbers: " &
Round((CurrentNumber / (LastNum * LastYear)) * 100, 2) & "%"
Next
'Export the full Array to Access
'Put export code here......
Application.StatusBar = "Exporting to Access."
Next
Application.StatusBar = ""
End Sub
Thanks
EM