excel - Evaluate a Range and Write in Another Column Based on a Row Entry -


i want in range , find flag values, populate same row in column based on values.

column 1       column 2 code1 code10 

if specify code1 in macro, want populate column 2.

i have following code. runtime error. how can avoid runtime error.

sub test()  sheets("sheet1")      set r = .range("a:a").find(what:="old", lookin:=xlvalues)     dim rownum long     rownum = r.row     dim rownum2 long     rownum2 = rownum - 1      sheets("sheet1")          set r2 = .range("c6:c" & rownum2)         dim cell variant          each cell in r2            if cells.value = ("code1" or "code2" or "code3" or "code4")                 .select                 .offset(0, 7).value = "special"             end if         next cell      end  end  end sub 

i cleaned little:

sub test() dim r2 range dim rownum2 long dim cell range  sheets("sheet1")     rownum2 = .range("a:a").find(what:="old", lookin:=xlvalues).row - 1     set r2 = .range("c6:c" & rownum2) end  each cell in r2     if cell.value = "code1" or cell.value = "code2" or cell.value = "code3" or cell.value = "code4"         cell.offset(0, 7).value = "special"     end if next cell  end sub 

the main issue if statement. see above proper method of using or statement.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -