excel - For loop and if statement to copy in another sheet -


i trying check cells 2 columns (one loop each) , see whether have string true. if yes copy cells corresponding, sheet(log).

i know have cells, contain word true when run program there nothing copied in other sheet.

i not compiling errors , know wrong in code.

sub islimit()      dim long, b long, lr long      x = 2     y = 2     lr = worksheets("targets").cells(rows.count, "a").end(xlup).row       = 8 lr     if (strcomp(cells(i, 15).text, "true")) = 0     worksheets("log").range("b" & x) = "no"     x = x + 1     end if     next      j = 8 lr     if (strcomp(cells(j, 16).text, "true")) = 0     worksheets("log").range("b2") = worksheets("targets").range("b1").value     worksheets("log").range("c" & y) = "yes"     y = y + 1     end if     next j  end sub 

so far, can see 2 problems might causing trouble.

1.since not setting sheets checked line below,

it check activesheet cells i,15 return -1 or 0 (true or false).

which work when screen displays sheet data stored.

if (strcomp(cells(i, 15).text, "true")) = 0 

2.if data contains else true (for example space before or after value).

it might see other "true"

that's can tell without looking @ actual data.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo