excel vba - Assistance with comparing cells with If formula -


i comparing cells in column d , if match paste value of previous cell in column b next cell in column b if not match paste value of subseqent cell in column a cell in column b

e.g

if(d2=d3,b2,a2+1)" not working after running on 1st sequence of cells in d #valve!" rest of column b

i sure problem if(d2=d3,b2,a2+1)" in-particular a2+1 reference not sure how call it

(sorry if unclear)

thanks

sub targetid() dim lrow long dim ws worksheet  set ws = sheets("unpivot") columns("b:b").select selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove   range("b1").formular1c1 = "source"  range("b2").formular1c1 = [a2].value  ws lrow = ws.range("d" & .rows.count).end(xlup).row     .range("b3:b" & lrow)         .formula = "=if(d2=d3,b2,a2+1)"         .value = .value    end end   end sub 

as follow comments, 1 works:

with .range("b3:b" & lrow)     .formula = "=if(d2=d3,b2,a3)"     .value = .value end 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -