Pompoire


Dear All,

I have a question, I want to sum some values if a reference is equal to a date that I implemented in a cell that I defined as name (defined as string)

name changes in a loop.

I used the following formula

ActiveCell.FormulaR1C1 = "=SUMIF(R[-2]C10:R[-2]C100,"" = name"",RC[7]:RC[84])"

unfortunatelly it does not take the VALUE of the name variable but it writes it as =name.

how can I force in my program that the value will be taken into account and not the formula which is behind

thank you in advance

Pompoire



Re: VBA read a value and not a formula

Shasur


As the 'name' is within doube quote it is considered as literal string in the formula

Try the way as used below:

name = "A1=10"
ActiveCell.FormulaR1C1 = "=SUMIF(R[-2]C10:R[-2]C100," & name & ",RC[7]:RC[84])"

Cheers

Shasur






Re: VBA read a value and not a formula

Pompoire

thanks and it almost works....

It is on the good way but it does not sumif the value is equal to name.

how to write = name in the formula

Cheers

Pompoire






Re: VBA read a value and not a formula

Peter Mo.

Hi

As you say almost there. Try ..

ActiveCell.FormulaR1C1 = "=SUMIF(R[-2]C10:R[-2]C100,""=" & name & """,RC[7]:RC[84])"

Regards

Peter Mo