See the attached File :

                

 

Sub FLoop()

 Dim i As Integer

  Range("A1").Value = "Example By For Loop"

  Range("A2").Select

  

    For i = 1 To 20

                ActiveCell.Value = "i am In For Loop " & i & " time and My
value is " & i

                ActiveCell.Offset(1, 0).Select

    Next

 End Sub

 

 

 Sub DoLoop()

 Dim i As Integer

  Range("A1").Value = "Example By Do Loop"

  Range("A2").Select

  i = 0

                Do

                i = i + 1

                ActiveCell.Value = "i am In Do Loop " & i & " time and My
value is " & i

                ActiveCell.Offset(1, 0).Select

                Loop Until i = 20

    

 End Sub

 

 

Sub WhileLoop()

 Dim i As Integer

  Range("A1").Value = "Example By While Loop"

  Range("A2").Select

  i = 0

                While i <> 20

                i = i + 1

                ActiveCell.Value = "i am In While Loop " & i & " time and My
value is " & i

                ActiveCell.Offset(1, 0).Select

                Wend

    

 End Sub

 

 

Sub LableLoop()

 Dim i As Integer

  Range("A1").Value = "Example By lable and Goto"

  Range("A2").Select

  i = 0

CC:

     

              i = i + 1

                ActiveCell.Value = "i am In Goto Loop " & i & " time and My
value is " & i

                ActiveCell.Offset(1, 0).Select

     If i <> 20 Then

     GoTo CC:

     Else

     Exit Sub

     End If

 End Sub

 

 

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of neil johnson
Sent: Monday, July 25, 2011 9:24 PM
To: excel-macros
Subject: $$Excel-Macros$$ Please explain about loop

 

Hi All,

 

Please explain loop with real example in sheets . much appreciated if you
will provide attached sheet with example of loop .

 

Thanks

-- 
----------------------------------------------------------------------------
------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
 
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Attachment: Loop Example.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12

Reply via email to