array from range question

G

Gary Keramidas

i am using this to populate an array
arr = .Range("B12:B" & lRow).Value
then i use this to work with the array
For x = LBound(arr) To UBound(arr)
If arr(x, 1) > "" Then

the problem is when lrow = 12 (only 1 element in array), i get a type mismatch.
how can i get around it?
 
N

Norman Jones

Hi Gary,

One way, try something like:

Arr = Range("B12:B" & LRow).Value
'then i use this to work with the array
If IsArray(Arr) Then
For x = LBound(Arr) To UBound(Arr)
If Arr(x, 1) > "" Then
'do someting,e.g.:
MsgBox Arr(x, 1)

End If
Next x
Else
If Not IsEmpty(Arr) Then
'do something
MsgBox Arr
End If
End If
 
G

Gary Keramidas

i'll give it a shot, norman.
as a temporary fix i just set the lrow to 13 when it = 12, so the client could
enter some data they needed to get in.
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top