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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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