having probelms getting my loop to terminate on an array value read from an empty cell

  • Thread starter Thread starter mizcrab
  • Start date Start date
M

mizcrab

This is my data stored in a column.

Team 1
Team 2
Team 3
Team 4
QC

I read in the data using
Do Until iempty = 5 ' get names of teams
If IsEmpty(Worksheets("teams").Range("A" & irow)) Then
iempty = iempty + 1
irow = irow + 1
Else
Teamnames(iteam) = Worksheets("teams").Range("A" & irow)
irow = irow + 1
iteam = iteam + 1
iempty = 1
If icount = 100 Then
Exit Sub
End If

End If

Loop
The data reads in correctly and I am able to write it to another
column.

I have tried to terminate the below do until loop using Null, "",
vbNull, 0 or using an IsEmpty(teamnames(iteam))

Do Until Teamnames(iteam) = ""


nothing works. without the exit sub command, I get into an infinite
loop. can anyone please help?

Do Until Teamnames(iteam) = vbNull
icount = icount + 1
iteam = iteam + 1
MsgBox "teamnames(iteam)= " & Teamnames(iteam) & " iteam = " &
iteam
If iteam = 10 Then
Exit Sub
End If
Loop
 
Try

Do Until IsEmpty(Teamnames(iteam))

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
I appreciate the quick response. I tried IsEmpty(Teamnames(iteam)) and
it did not work. Do i need to intialize my array to use isempty?
isempty worked when I was reading in my data and looking for empty
cells.
thanks
 
Normally, dimensioning the arry creates empty placeholders, but if you fill
them all, there should be no empties.

So how about

Do Until Isempty (Teamnames(iteam)) Or _
iteam > UBound(Teamnames)
--

HTH

RP
(remove nothere from the email address if mailing direct)
 
I found a solution. I had dimensioned the array as teamnames As string
* 50, so it was initilializing my array with 50 spaces. it works now
that I took out the *50
 

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

Back
Top