# Loop through visible cells only



## Shweta

Hi All,

How can we loop through visible cells only?

Actually I am using filter and I want to run a for loop on filtered data only. How can I do this?

Please help me out on this.

Thanks in advance!

Regards,
Shweta


----------



## MARK858

Something like?



		Code:
__


Sub SpecialLoop()
    Dim cl As Range, rng As Range
    Set rng = Range("A2:A100")
    For Each cl In rng.SpecialCells(xlCellTypeVisible)
        Debug.Print cl
    Next cl
End Sub


----------



## Shweta

Thanks a lot !

It's working fine for me.


----------



## Sunil7598

MARK858 said:


> Something like?
> 
> 
> 
> Code:
> __
> 
> 
> Sub SpecialLoop()
> Dim cl As Range, rng As Range
> Set rng = Range("A2:A100")
> For Each cl In rng.SpecialCells(xlCellTypeVisible)
> Debug.Print cl
> Next cl
> End Sub


Hi,

it's very usefull, but how can I use it in a loop like this

for i = 2 to lrow

next i


----------

