Reputation: 4556
How would I go about turning the excel formula =B4/B5 into vba code? So far, this is my code which does not work of course:
ActiveCell.FormulaR1C1 = "=B4/B5"
As you can tell, I am not very familiar with R1C1. If needed, I have created a function Col_Letter()
which takes a number and returns the letter of the corresponding column. Any help would be greatly appreciated!
Upvotes: 0
Views: 187
Reputation: 21563
As pointed out in the comments by @siddarth you are looking for:
ActiveCell.Formula = "=B4/B5"
If you are in a hurry and just need to make the macro work, a compromise on code readability may be acceptable. In that case you could do the following:
Note that this will work for nearly everything, but may lead to somewhat confusing code.
Upvotes: 3