KEMBAR78
Syntax: Do... Loop Statement | PDF
0% found this document useful (0 votes)
46 views6 pages

Syntax: Do... Loop Statement

The document describes two VBA looping structures: 1. The Do...Loop statement repeats a block of statements while or until a condition is True. It has optional Exit Do and Loop statements. 2. The For...Next statement repeats a group of statements a specified number of times, using a counter variable from a start to end value, optionally in steps. It requires Counter, Start, and Next parts.

Uploaded by

av_meshram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views6 pages

Syntax: Do... Loop Statement

The document describes two VBA looping structures: 1. The Do...Loop statement repeats a block of statements while or until a condition is True. It has optional Exit Do and Loop statements. 2. The For...Next statement repeats a group of statements a specified number of times, using a counter variable from a start to end value, optionally in steps. It requires Counter, Start, and Next parts.

Uploaded by

av_meshram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 6

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

You might also like