excel - R1C1 Formula: Using Row counter for R[ ] -


im trying use row counter make range countif. giving me error every time run , suspect syntax error. thoughts?

dim nrows integer 'row counter nrows = range(range("b4"), range("b4").end(xldown)).rows.count  range("y5").select activecell.formular1c1 = _   "=if(countif("r5c5:r" & nrows & "c5",rc[-20])>=2,""duplicate account combination"","""")" range("y5").select selection.autofill destination:=range("y5:y" & nrows) 

i believe issue @ "=if(countif("r5c5:r" & nrows & "c5",rc[-20])>=2," part of code.

the problem having in fact in line suspected was. problem escaping string @ wrong time. need change quotation marks such:

activecell.formular1c1 = _ "=if(countif(r5c5:r" & nrows & "c5,rc[-20])>=2,""duplicate account combination"","""")" 

note debug this, easiest way set equal string, such as:

dim teststring teststring = "=if(countif(r5c5:r" & nrows & "c5,rc[-20])>=2,""duplicate account combination"","""")" activecell.formular1c1 = teststring 

this way if isn't working, can debug.print teststring , paste string actual excel cell. make easier see problem.

while testing it, note need make sure excel set r1c1 notation, otherwise cause error while testing. per byron wall's comment, don't need set in style vba work, if pasting excel test.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -