Rhino_Dance
Board Regular
- Joined
- Jul 23, 2008
- Messages
- 74
The following vba line successfully inserts a Substitute Formula into one cell that refers to another cell 46 columns to the left:
ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-46],BoxPipe2,""|"")"
I want to replace the 46 with a numeric variable called 'nc'. But I get an error when I try to run the line which is shown below. The variable is definitely equal to 46. Can someone tell me why this doesn't work?
ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-nc],BoxPipe1,""|"")"
(Also I'm using SUBSTITUTE because the CELLS.REPLACE method does not always work for this case due to the imported characters I'm replacing.)
Thanks
ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-46],BoxPipe2,""|"")"
I want to replace the 46 with a numeric variable called 'nc'. But I get an error when I try to run the line which is shown below. The variable is definitely equal to 46. Can someone tell me why this doesn't work?
ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-nc],BoxPipe1,""|"")"
(Also I'm using SUBSTITUTE because the CELLS.REPLACE method does not always work for this case due to the imported characters I'm replacing.)
Thanks