0

I am using the below code to add a formula to a cell:

Cells(1, 1).FormulaR1C1 = 
"=RC" & Range("Col2").Column & 
"-RC" & Range("Col28").Column & 
"-RC" & Range("Col54").Column

What I'm expecting in Cell A1:

=B1-AB1-BB1

What happens is:

=B1-AC1-BD1

From column AA it is shifted by one column and from column BA by two columns.

In which area (A to Z or AA to AZ or BA to BZ) the linked cells are located is only known at runtime. Therefore it does NOT work:

Cells(1,1).FormulaR1C1 = 
"=RC" & Range("Col2").Column & 
"-RC" & Range("Col28").Column -1 &
"-RC" & Range("Col54").Column -2
Änna
  • 1
  • 1

0 Answers0