ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reference adjacent cells in formulae (https://www.excelbanter.com/excel-programming/357418-reference-adjacent-cells-formulae.html)

pkeegs

reference adjacent cells in formulae
 
I have a macro which loops till a criteria is met. I then want it to insert a
formulae using the two cells immediately to the left of the active cell. Then
it will continue to loop until the criteria is met again and the formula
again inserted. How can I get the macro to reference those cells to the left
in the same row. Below is what I currently have with a "?" being the row that
I am currently in. I have tried using "#" and a combination of Offsets
without much joy.
ActiveCell.Offset(0, 8).Select (being Column "I")
With Selection
.Formula = "=$G?-$H?"
End With

Norman Jones

reference adjacent cells in formulae
 
Hi P,

Try:

ActiveCell.Offset(0, 8).FormulaR1C1 = "=RC[-2]-RC[-1]"


---
Regards,
Norman



"pkeegs" wrote in message
...
I have a macro which loops till a criteria is met. I then want it to insert
a
formulae using the two cells immediately to the left of the active cell.
Then
it will continue to loop until the criteria is met again and the formula
again inserted. How can I get the macro to reference those cells to the
left
in the same row. Below is what I currently have with a "?" being the row
that
I am currently in. I have tried using "#" and a combination of Offsets
without much joy.
ActiveCell.Offset(0, 8).Select (being Column "I")
With Selection
.Formula = "=$G?-$H?"
End With





All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com