-- Single For Loop
Dim x As Integer
For x = 1 To 10
Cells(x, 1).Value = x
-- Exit For (can be used to exit)
Next x
-- 2 For loops
Dim x As Integer
Dim y As Integer
For x = 1 To 3
For y= 1 To 10
Cells(y, x).Value = y &"-"& x
Next y
Next x
-- 3 For loops
Dim x As Integer
Dim y As Integer
Dim z As Integer
For z = 3 To 6
For x = 1 To 3
For y = 1 To 10
Worksheets(z).Cells(y , x).Value = "ERPstuff"
Next y
Next x
Next z
-- For Each Loop
Dim ws As Worksheet
For Each ws In Worksheets
MsgBox ws.Name
Next ws
FOR Loops Syntax in VBA
FOR Loops Syntax in VBA
Malik Sikandar Hayat
admin@erpstuff.com
admin@erpstuff.com
Who is online
Users browsing this forum: No registered users and 1 guest