PDA

View Full Version : Add on additional range in Loop



coliervile
12-09-2013, 09:39 AM
Good Day everyone,

This code was provided to me by "xld", thanks "xld" for your help. The code loops through Sheet "Class 9" range D11:D19 until all of the True values are gone. I want to add on an additional range, as well as range D11:D19, on the same sheet H11:H19 until all of True vales are gone as well as D11:D19.



Public Sub test()
Dim cnt As Long
.Calculate
With Sheets("Class 9")
.Calculate
Do While Application.CountIf(.Range("D11:D19"), "TRUE") > 0

.Calculate
cnt = cnt + 1
Loop


End With
End Sub.

coliervile
12-09-2013, 11:05 AM
I think that I found out my answer with this code...


Public Sub test()

Dim cnt As Long

With Sheets("Class 9")
.Calculate
Do While Application.CountIf(.Range("D11:D19", "H11:H19"), "TRUE") > 0

.Calculate
cnt = cnt + 1
Loop

End With

Thus far I'm not getting errors after about 50 runs of the code. If anyone sees an error please let me know.