troubleshooting Question

Specifying boundary of an array with a variable

Avatar of Diane Lonergan
Diane LonerganFlag for United Kingdom of Great Britain and Northern Ireland asked on
VBA
1 Comment1 Solution31 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros