View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mizcrab mizcrab is offline
external usenet poster
 
Posts: 3
Default having probelms getting my loop to terminate on an array value read from an empty cell

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