Please suggest the solution to iterate 800 rows in Excel 2003 for hiding and unhiding the rows.
For i = 0 To WSTreatmentOutComes.Range("F14:F813").Rows.Count - 1
If WSTreatmentOutComes.Range("F" & 14 + i).Value = "" Or WSTreatmentOutComes.Range("F" & 14 + i).Value = "0" Then
For j = 0 To 9
WSTreatmentOutComes.Range("F" & 14 + i + j).Rows.Hidden = True
Next j
Else
For k = 0 To 9
If WSTreatmentOutComes.Range("G" & 14 + i + k).Value = "" Or WSTreatmentOutComes.Range("G" & 14 + i + k).Value = "0" Then
WSTreatmentOutComes.Range("F" & 14 + i + k).Rows.Hidden = True
End If
Next k
End If
i = i + 9
Next i
in column A put a formula test like this:
Range("A14:A813").formula="=IF(AND(F:F="""",G:G=0),NA(),"""")"
then use code like this to hide or unhide:
finally, clean up column A:
Range("A14:A813").clearcontents
there you go, hides them instantly
more on this method/technique at StackOverFlow: how-to-delete-multiple-rows-without-a-loop-in-excel-vba
With this code I hide the rows where the A column is "1":
So if you want to hide rows if a certain condition in that row is met, you just have to adapt the If-condition and the range.
It seems you should be able to get rid of the inner loop by just hiding the block all in one go. Something close to this should work:
also, without seeing the start of your code, are you turning off ScreenUpdating at the start?
This is how I would do it: