Forum Discussion
run-time error 1004
- May 30, 2018
Hello Lorenzo,
Please make this correction:
ActiveCell.FormulaR1C1 = "=SUM(R[-" & Trim(Str(LastRow)) & "]C:R[-1]C)"
Since we are writing a string in .FormulaR1C1, therefore the value we are passing being a variable needs to be negotiated independently and not in a string. So when we put a number directly it takes the value directly, whereas when we write a variable, it needs to retrieve its value, which in string reads as string LastRow. Giving it independent of string allows to take its value.
Hope this helps.
Hello Lorenzo,
Please make this correction:
ActiveCell.FormulaR1C1 = "=SUM(R[-" & Trim(Str(LastRow)) & "]C:R[-1]C)"
Since we are writing a string in .FormulaR1C1, therefore the value we are passing being a variable needs to be negotiated independently and not in a string. So when we put a number directly it takes the value directly, whereas when we write a variable, it needs to retrieve its value, which in string reads as string LastRow. Giving it independent of string allows to take its value.
Hope this helps.
- PascalTriangleFeb 14, 2019Copper Contributor
Sanjay Gandhi wrote:Hello Lorenzo,
Please make this correction:
ActiveCell.FormulaR1C1 = "=SUM(R[-" & Trim(Str(LastRow)) & "]C:R[-1]C)"
Since we are writing a string in .FormulaR1C1, therefore the value we are passing being a variable needs to be negotiated independently and not in a string. So when we put a number directly it takes the value directly, whereas when we write a variable, it needs to retrieve its value, which in string reads as string LastRow. Giving it independent of string allows to take its value.
Hope this helps.
I having Problem with this and i couldnt post in this community, sorry if i violates the rule.
- Lorenzo KimMay 30, 2018Bronze Contributor
Mr. Gandhi
It worked perfectly.
THANK YOU VERY MUCH!!