Help needed to understand VBA codes

freeisgood

New Member
Joined
Jan 18, 2008
Messages
31
Hello All,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I am learning VBA and the material that I am reading provided me with an example along with a quick explanation. I understood variable “marks” and “d”. but for the 4<SUP>th</SUP> line of codes below “For Each c In marks”, does it means “c” represent each cell in the range of A1 to B10? If not please explain the meaning of that line.<o:p></o:p>
<o:p> </o:p>
Codes:<o:p></o:p>
<o:p> </o:p>
Dim marks, c, d<o:p></o:p>
Set marks = Range("A1:B10")<o:p></o:p>
d = 0<o:p></o:p>
For Each c In marks<o:p></o:p>
If c.Value < 40 Then<o:p></o:p>
d = d + 1<o:p></o:p>
End If<o:p></o:p>
Next c<o:p></o:p>
<o:p> </o:p>
Thank you<o:p></o:p>
VL<o:p></o:p>
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hello All,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I am learning VBA and the material that I am reading provided me with an example along with a quick explanation. I understood variable “marks” and “d”. but for the 4<SUP>th</SUP> line of codes below “For Each c In marks”, does it means “c” represent each cell in the range of A1 to B10? If not please explain the meaning of that line.<o:p></o:p>
<o:p> </o:p>
Codes:<o:p></o:p>
<o:p> </o:p>
Dim marks, c, d<o:p></o:p>
Set marks = Range("A1:B10")<o:p></o:p>
d = 0<o:p></o:p>
For Each c In marks<o:p></o:p>
If c.Value < 40 Then<o:p></o:p>
d = d + 1<o:p></o:p>
End If<o:p></o:p>
Next c<o:p></o:p>
<o:p> </o:p>
Thank you<o:p></o:p>
VL<o:p></o:p>

You're absolutely right.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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