1
1
1
1
1
1
1
1
1
1
1
1
1
1
100
101
102
103
104
105
106
107
108
109
110
111
112
113
100
100
100
100
100
100
100
100
100
100
100
100
100
100
200
201
202
203
204
205
206
207
208
209
210
211
212
213
Do...Loop Statement
Repeats a block of statements while a condition is Tr
Syntax
Do [{While | Until} condition]
[statements]
[Exit Do]
[statements]
Loop
Or, you can use this syntax:
Do
[statements]
[Exit Do]
[statements]
Loop [{While | Until} condition]
nts while a condition is True or until a condition becomes True.
n]
ion]
101
102
103
104
105
106
107
108
109
110
102
104
106
108
110
112
114
116
118
120
103
102
For...Next Statement
109
108
Repeats a group of statements a specified number of times.
115
Syntax
121
114
127
120
120
For counter = start To end [Step step]
[statements]
[Exit For]
[statements]
Next [counter]
The ForNext statement syntax has these parts:
Part
counter
start
end
step
statements
Description
Required. Numeric variable used a
Required. Initial value of counter.
Required. Final value of counter.
Optional. Amount counter is change
Optional. One or more statements b
ecified number of times.
p]
s these parts:
on
Numeric variable used as a loop counter. The variable can't be a Boolean or an array element.
Initial value of counter.
Final value of counter.
Amount counter is changed each time through the loop. If not specified, step defaults to one.
One or more statements between For and Next that are executed the specified number of times.
Opening a Workbook
When you open a workbook using the Open method, it becomes a member of the Workbooks collection. The following p
located in the folder named MyFolder on drive C.
Sub OpenUp()
Workbooks.Open("C:\MyFolder\MyBook.xls")
End Sub
Load Data
Clear Data
oks collection. The following procedure opens a workbook named MyBook.xls