Link to home
Start Free TrialLog in
Avatar of Diane Lonergan
Diane LonerganFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Specifying boundary of an array with a variable

i am trying to create a temp array with the first dimension being set to the ubound of another array, as my temp array will need to have the same number of rows. so here is a sample of my code

Dim AbsenceArray As Variant     'declare my asbence array, this populated by absences for all staff
AbsenceArray = Range("a1").CurrentRegion  'populate my array
ReDim Preserve AbsenceArray(1 To UBound(AbsenceArray, 1), 1 To UBound(AbsenceArray, 2)) 'resize my array and drop header

GetUbound = UBound(AbsenceArray, 1) 'using this to get ubound of absence array and will later use to set unbound of temp array

Dim TempArray(1 To GetUbound, 1 To 2) As Integer    'create my temp array

My code errors on the GetUbound variable, if I put in a static number of course it works with no error. Can someone please advise correct syntax. Thanks
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial