loops - Excel VBA: Using a variable when defining a list as a String -
pretty new vba i'm learning quickly.
i'm getting used using loops perform repetitive tasks, , in case, want each pass through loop define different variable. i'd defining list string , pushing value each part of list each loop.
obviously, number of loops variable, need end point of defined list variable. i've searched, that's not possible? i'm getting "constant expression required" error.
here code (lastrow defined):
nextaverage = 0 section = 1 dim averagesection(1 section) string section = 1 phrasesections activecell.formula = "=match(""average"",a" & nextaverage + 1 & ":a" & lastrow & ",0)" selection.offset(1, 0).select activecell.formula = "=sum(g1:g" & section & ")" nextaverage = activecell.value averagesection(section) = activecell.value next section
any appreciated!
try using redim preserve:
dim averagesection() string section = 1 phrasesections redim preserve averagesection(section) ... next section
does help?
Comments
Post a Comment