# Thread: array from datasheet question

1. ## array from datasheet question

aC=xlsh.UsedRange
returns a two dimensional array when there is more than one cell of data. With one cell of data it returns a string or integer variable.
I need to turn the single item into an array to be consistent with reading the value from an array.
I tried:
Array(aC,"") = aC
Array("",aC) = aC
Array(1,0) = aC
Array(0,1) = aC
I dont think that I can do a redim because I did not declare it as ac() with parenthis.

[/code]
Dim aC,strAC
aC = xlsh.UsedRange ' This gets the entire sheet into the array.
' If there is only one cell used in the sheet UFT returns a variable and not an array. We need to force an array with 1 element.
If Not isarray(aB) Then
strAC = aC
aC(1,1) = strAC
End If
[code]

2. This finally worked:
[/Code]
If Not isarray(aC) Then
strAC = aC
ReDim aC(1,1)
aB(1,1) = strAC
End If
[Code]

3. Glad you got it sorted. I would have attacked it this way, in case you're the curious sort.

Code:
`If Not IsArray(aC) Then aC = Array(aC)`
That'd make it into a single dimension array. If you then needed it to be multi-dimensional, you could ReDim it.

Code:
`ReDim Preserve aC(0,0)`

4. Dennis,
I appreciate the alternative technique.
Thanks,
Kevin

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.