excel - doing a loop without "predefining" cells (ie just "B" instead of "b5") -
here's problem: i'm trying run loop on specific set of data, amount changes each update. if score >0, cut/paste specific row in columns a,b&c in next available free row in sheet data. have till now:
sub whatever() dim score integer, sstart integer, steller integer, lcount integer, result string sstart = sheets("packed").range("f1").value steller = sheets("packed").range("e1").value lcount = sstart score = range("b& lcount").value while lcount < steller sheets("packed").select if score > 0 _ range("a&lcount:c&lcount").select selection.cut sheets("data").select range("a5").select selection.end(xldown).select selection.offset(1, 0).select activesheet.paste lcount = lcount + 1 loop end sub
what vba adds "lcount" rowlabel , loops each row in b there data. in advance :)
you including many 'pieces' when concatenating quoted string in code:
if score > 0 _ range("a&lcount:c&lcount").select
here suggestions:
if score > 0 _ range("a" & lcount & ":c" & lcount).select if score > 0 _ cells(lcount, "a").resize(1, 3).select
you may want review methods detailed in how avoid using select in excel vba macros.
Comments
Post a Comment