Q: is this continually looping?

S

ste mac

Many thanks for taking the time to have a look at my problem.

The code below does what its supposed to do in a nansecond
The problem is, after it has produced the answer it carries
on running, is it continually looping?
I was hoping one of you guys can see what i have done wrong
or offer a better solution... cheers..

seeya ste

Public sSheetOne As String
Public hRow As Long
Public hCol As Long
Public sRow As Long
Public sCol As Long
Public lHits(5) As Long
Public lThishit As Long
Public lx As Long

Public Sub HistoryCheck()

sSheetOne = "Data Control"

sRow = 2

Do While Not Sheets(sSheetOne).Cells(sRow, 1).Value = ""

CheckThisData

UpdateTotals

Loop

End Sub
---------------------------------------
Private Sub CheckThisData()

For lx = 0 To 5
lHits(lx) = 0
Next

hRow = 2

Do While Not Sheets(sSheetOne).Cells(hRow, 1).Value = ""

lThishit = 0

For hCol = 2 To 6
For sCol = 9 To 13

If (Sheets(sSheetOne).Cells(hRow, hCol).Value =
Sheets(sSheetOne).Cells(sRow, sCol).Value) Then
lThishit = (lThishit + 1)
End If
Next
Next

lHits(lThishit) = (lHits(lThishit) + 1)

hRow = (hRow + 1)

Loop

End Sub
--------------------------------------
Private Sub UpdateTotals()

For lx = 0 To 5
Sheets(sSheetOne).Cells(sRow, (14 + lx)).Value = lHits(lx)
Next

End Sub
 
B

Bob Phillips

Taking a quick look at it, it certainly looks to be looping. As I see it,
you are doing a loop based upon column A in row sRow being empty, but you
don't seem to increment sRow anywhere. You should add 1 within the Do Loop

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
S

ste mac

Thanks Bob, l will have a look...

seeya ste


Bob Phillips said:
Taking a quick look at it, it certainly looks to be looping. As I see it,
you are doing a loop based upon column A in row sRow being empty, but you
don't seem to increment sRow anywhere. You should add 1 within the Do Loop

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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