strCount = 0
set rng = Columns(1).Find(strBranch)
if not rng is nothing then
sAddr = rng.Address
do
Rowdates2 = rng.row
If Cells(rowdates2, "B") = strRef And _
Cells(rowdates2, "E") = strPCode And _
Cells(rowdates2, "I").Value = strRegNo And _
Cells(rowdates2, "J").Value = strTranDate And _
Cells(rowdates2, "K").Value = strTranType Then
if strcount < 0 then
'process the rng
' exit Do
else
strCount = strcount + 1
end if
end if
set rng = columns(1).FindNext(rng)
Loop until rng.Address = sAddr
End If
--
Regards,
Tom Ogilvy
"andycharger " wrote in message
...
Hi guys,
Long time no post! Anyway, I got a little poser for you....
My code is taking forever to run. I have a looping statement that has
about 6 or 7 nested if statements.
Basically, It says the following
[vb]
For rowdates2 = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(rowdates2, "A") = strBranch Then
If Cells(rowdates2, "B") = strRef Then
If Cells(rowdates2, "E") = strPCode Then
If Cells(rowdates2, "I").Value = strRegNo Then
If Cells(rowdates2, "J").Value = strTranDate Then
If Cells(rowdates2, "K").Value = strTranType Then
strCount = strCount + 1
Else
End If
Else
End If
Else
End If
Else
'do nothing
End If
Else
'do nothing
End If
Else
'do nothing
End If
Next
[/vb]
If it gets a match, it increases the counter by 1. (strCount)
What I need it to do instead is if the counter is bigger than 0, do
something. However, I do remember something about FIND in VBA.
How can I get the number of matches (count) back by using the FIND
statement? It would be quicker than using the loop.
Any ideas let me know
---
Message posted from http://www.ExcelForum.com/