for each ws in sheets/ for each xcell in range

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I see these code like below and I wonder what is the rule? or how people came with this? or what is the syntax.
For example

dim ws as worksheet
for each ws in sheets

or

dim xcell as cells
for each xcell in range

Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What rule ?
It's just simply an abbreviation of Worksheets / Cells.
You could also use


dim w as worksheet
for each w in sheets

so you don't have to say "worksheets" every time, you say "w"
 
Upvote 0
Thank you very much for your reply. No I did not mean the WS, Xcell etc. I meant the For loop. I know the For loop like this

For x = 1 to 100

But to say "For each ws in worksheets" is something I do not understand? I mean I understand the meaning but How people come with this idea? Same apply for the cell for example

For each xcell in range

Thank you
 
Upvote 0
For x = 1 to 100....is simply using x as a variable integer

For each ws in worksheets...is using ws as an object worksheet among ALL the worksheets.

Beyond that, I don't know how else to explain it.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top