excel vba - VBA Copy IF Value Equals -
i wonder whether may able me please.
firstly, i'm first admit, i've received stage, i'm little unsure past issue have code below.
to give little background:
what i'm trying do, perform check code looks @ list of projects on sheet "alldata" (source) sheet, starting @ cell e3, , copies cell if contains text value "enhancements" , pastes "enhancements" (destination) sheet.
in addition, code takes 'actuals' manhour figure , date associated each project , totals manhours project , period respective cells on destination sheet (enhancements sheet). these "rval" , "rdate" variables.
revised code - full working script
sub extract() dim long, j long, m long dim strproject string dim rdate date dim rval single dim blnprojexists boolean sheets("enhancements").range("b3") = 1 .currentregion.rows.count - 1 j = 0 13 .offset(i, j) = "" next j next end with sheets("alldata").range("e3") = 1 .currentregion.rows.count - 1 strproject = .offset(i, 0) if instr(strproject, "enhancements") = 0 goto nextloop end if rdate = .offset(i, 3) rval = .offset(i, 4) sheets("enhancements").range("b3") if .currentregion.rows.count = 1 .offset(1, 0) = strproject j = 1 else blnprojexists = false j = 1 .currentregion.rows.count - 1 if .offset(j, 0) = strproject blnprojexists = true exit end if next j if blnprojexists = false .offset(j, 0) = strproject end if end if select case format(rdate, "mmm yy") case "apr 13" m = 1 case "may 13" m = 2 case "jun 13" m = 3 case "jul 13" m = 4 case "aug 13" m = 5 case "sep 13" m = 6 case "oct 13" m = 7 case "nov 13" m = 8 case "dec 13" m = 9 case "jan 14" m = 10 case "feb 14" m = 11 case "mar 14" m = 12 end select .offset(j, m) = .offset(j, m) + rval end nextloop: next end end sub
unfortunately when try run receive 'compile error: label not defined' error, , debug highlights following line problem , i'm not sure why:
goto nexti
i wondered whether possibly @ please , let me know i've gone wrong?
if helps, can provide link test file.
many , kind regards
you're not doing differently when value "enhancements". change this:
if instr(.offset(i, 0), "enhancements") > 0 strproject = .offset(i, 0) end if
to this:
if instr(strproject, "enhancements") = 0 goto nextloop end if
and add nextloop identifier before "next i":
end nextloop: next end end sub
Comments
Post a Comment