vba - Nested Loops & Ifs, loop without Do -
i keep getting loop without every time run code , not see missing or if loop misplaced. need code find key words in specific columns copy paste them summary tab.
your appreciated.
sub summary() dim mainloop double dim secondloop double dim thirdloop double dim trow double dim counter integer dim psku integer dim pdesc string dim ppkg integer dim csku integer dim cdesc string dim cpkg integer dim cstatus string mainloop = 5 secondloop = 0 thirdloop = 0 trow = 5 counter = 0 worksheets("final").activate while mainloop < activesheet.cells(rows.count, "b").end(xlup).row worksheets("final").activate parentsku = range("f" & mainloop).value parentdesc = range("g" & mainloop).value worksheets("summary").activate sumrow = (activesheet.cells(rows.count, "a").end(xlup).row) + 1 range("a" & sumrow).value = parentsku range("b" & sumrow).value = parentdesc range("c" & sumrow).value = "parent" worksheets("final").activate while secondloop < 20 if range("h" & mainloop + secondloop).value = "mat" or "pkg" or "ing" range("f" & mainloop + secondloop).value = csku range("g" & mainloop + secondloop).value = cdesc range("h" & mainloop + secondloop).value = (cstatus) range("i" & mainloop + secondloop).value = cpkg worksheets("summary").activate sumrow = (activesheet.cells(rows.count, "a").end(xlup).row) + 1 range("a" & sumrow).value = csku range("b" & sumrow).value = cdesc range("c" & sumrow).value = "child" range("d" & sumrow).value = cpkg elseif range("h" & mainloop + secondloop).value = "wip" find = range("f" & mainloop + secondloop).value while trow < activesheet.cells(rows.count, "j").end(xlup).row & thirdloop < 20 if range("j" & trow).value = find if range("p" & trow + thirdloop).value <> "" csku = range("p" & trow + thirdloop).value cdesc = range("q" & trow + thirdloop).value cstatus = range("r" & trow + thirdloop).value cpkg = range("s" & trow + thirdloop).value worksheets("summary").activate sumrow = (activesheet.cells(rows.count, "a").end(xlup).row) + 1 range("a" & sumrow).value = csku range("b" & sumrow).value = cdesc range("c" & sumrow).value = "child" range("d" & sumrow).value = cpkg worksheets("final").activate thirdloop = thirdloop + 1 trow = trow + 1 else trow = trow + 1 end if else thirdloop = thirdloop + 1 end if loop end if secondloop = secondloop + 1 mainloop = mainloop + 20 loop worksheets("final").activate end sub
the following section missing end if
if range("p" & trow + thirdloop).value <> "" csku = range("p" & trow + thirdloop).value cdesc = range("q" & trow + thirdloop).value cstatus = range("r" & trow + thirdloop).value cpkg = range("s" & trow + thirdloop).value worksheets("summary").activate sumrow = (activesheet.cells(rows.count, "a").end(xlup).row) + 1 range("a" & sumrow).value = csku range("b" & sumrow).value = cdesc range("c" & sumrow).value = "child" range("d" & sumrow).value = cpkg worksheets("final").activate thirdloop = thirdloop + 1 trow = trow + 1 'missing end if here loop
Comments
Post a Comment