Oy!
Excel 2000
2 Worksheets: "Sample Report" & "Contracts"
Creating test data
"Sample Reports.xls" contains approx. 40,000 rows. I want to populate the entire 'Sample Report'!H:H column with randomly generated values based on the data in Contracts!A2:A14.
I have used
to successfully generate random dates for 'Sample Report'!A:A column.
I have tried
to accomplish my purposes, however it only populates 13 cells regardless of the number of cells selected. I would rather not repeat Cut and Paste 3077 times.
any ideas?
TIA
Excel 2000
2 Worksheets: "Sample Report" & "Contracts"
Creating test data
"Sample Reports.xls" contains approx. 40,000 rows. I want to populate the entire 'Sample Report'!H:H column with randomly generated values based on the data in Contracts!A2:A14.
I have used
Code:
Sub RandDates()
Dim MyRange As Range
Dim dtMin As Date, dtMax As Date
Dim dtRand As Date
' If selection is not Excel Range
If TypeName(Selection) <> "Range" Then Exit Sub
Set MyRange = Selection
' Get Min and Max value
' From: 1/1/1990 (put your start Date)
dtMin = #1/1/1990#
' To: Today
dtMax = Date
Randomize
Application.ScreenUpdating = False
For Each C In MyRange.Cells
' Calculate random value, where
' Value >= Min And Value <= Max
dtRand = Rnd * (dtMax - dtMin) + dtMin
dtRand = Int(dtRand)
C.Value = dtRand
' Change format for cell, below, as desired
C.NumberFormat = "m/d/yyyy"
Next C
Application.ScreenUpdating = True
End Sub
I have tried
Code:
Sub RandData()
Dim MyRange As Range
Dim MyArray() As Variant
' If selection is not Excel Range
If TypeName(Selection) <> "Range" Then Exit Sub
Set MyRange = Selection
MyArray = Range("Contract!$A$2:$A$14").Value
For C = 1 To MyRange.Count
MyRange.Value = MyArray
Next C
End Sub
any ideas?
TIA