ctillett18
New Member
- Joined
- Sep 10, 2019
- Messages
- 3
Hi - I'm trying to figure out how to write VBA code to insert a specific formula across a random selection of cells.
The gist of it is, that for whichever cells I have selected I want the code to write "= [EXISTING CELL VALUE] - adjacent cell".
My VBA code works as long as I only have a single cell selected ... how do I amend it to work on whichever cells I have selected? Code is below. I realize the issue is probably with the "ActiveCell" part of the code below, but I don't know how to get around it.
Sub CFS_2Q()
'
Selection.FormulaR1C1 = "=" & ActiveCell & "-RC[-1]"
'
End Sub
The gist of it is, that for whichever cells I have selected I want the code to write "= [EXISTING CELL VALUE] - adjacent cell".
My VBA code works as long as I only have a single cell selected ... how do I amend it to work on whichever cells I have selected? Code is below. I realize the issue is probably with the "ActiveCell" part of the code below, but I don't know how to get around it.
Sub CFS_2Q()
'
Selection.FormulaR1C1 = "=" & ActiveCell & "-RC[-1]"
'
End Sub