Monday, 15 February 2010

excel vba - Identifying the iteration of a For Each loop in VBA? -



excel vba - Identifying the iteration of a For Each loop in VBA? -

if have loop commences:

for each c in range("a1:c8")

is there property of placeholder c (c.count, c.value, c.something,...) identifies number of times loop has iterated far? rather utilize including variable.

instead of using "for each c in range" can this:

dim c long 'presumably did range, alter long. dim myrange range 'use range variable easier phone call on later set myrange = range("a1:c8") c = 1 myrange.cells.count 'do cell, identify myrange.cells(c), example: myrange.cells(c).font.bold = true '<--- replace code affects cell next

this allows exact same for/next loop, without including unnecessary counter variable. in case, c counter serves purpose of identifying cell beingness impacted code.

vba excel-vba foreach iteration

No comments:

Post a Comment