Question

I would like to assign a the values of a range to a user defined data type.

I have a dataset of measurements taken at mutliple times over the course of a week stored in an excel sheet. I have created a variable for the range of the data set. Then I created a user defined data type with date and single types. Now I would like to assign the values of the range to the user defined data type.

Data Set:

02/11/2011  3.8

02/11/2011  2.4

02/11/2011  8.9

02/12/2011  5.7

02/12/2011  4.6

02/12/2011  2.6

I've made a user define data type:

Type phData
    Dy As Date
    ph As Single
End Type

and created a variable of the phData type and matched the size to the range:

Dim dailyData() As tradeData
Dim nrec as Integer
nrec = dataRng.Rows.Count
ReDim dailyData(nrec)

and defined the range of the dataset on the excel spreadsheet:

Dim dataRng As Range
Set dataRng = Range("A2", Range("A2").End(xlDown).End(xlToRight))

and now I would like to assign the values in the range to the phData type. I can assign one value at a time using:

 dailyData(1).Dy= dataRng(1).Value

but I am need something more efficient as I have about 4,000 records.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top