m_graham_canada
New Member
- Joined
- Oct 11, 2007
- Messages
- 6
Hi there,
I'm using VBA in excel and want to do the following as I would have done in a worksheet:
I have simplified my example tremendously, but I think this is adequate.
suppose cell A1 has the number 2
suppose the cell B1 has the number 3
in cell A2 in excel I would type "=sum(A1,B1)"
in vba I want to do the same, BUT I don't know the actual cell address and I want the ability to copy to other cells using relative addressing.
So far I am able to code:
variable_x="=" & Cells(ProductLineRow(1), r1USD).Address & "+" & Cells(ProductLineRow(1), r2USD).Address
(The range(cells) just hasn't been working for me. Not sure why.)
So my equation is great, except the result is not relative. It gives me back =$A$1+$B$1 in my cell. I want to see =A1+B1.
I tried doing .address.indirect but vba doesn't like that either. Not sure of correct syntax.
Any thoughts how to do this?
Thanks.
I'm using VBA in excel and want to do the following as I would have done in a worksheet:
I have simplified my example tremendously, but I think this is adequate.
suppose cell A1 has the number 2
suppose the cell B1 has the number 3
in cell A2 in excel I would type "=sum(A1,B1)"
in vba I want to do the same, BUT I don't know the actual cell address and I want the ability to copy to other cells using relative addressing.
So far I am able to code:
variable_x="=" & Cells(ProductLineRow(1), r1USD).Address & "+" & Cells(ProductLineRow(1), r2USD).Address
(The range(cells) just hasn't been working for me. Not sure why.)
So my equation is great, except the result is not relative. It gives me back =$A$1+$B$1 in my cell. I want to see =A1+B1.
I tried doing .address.indirect but vba doesn't like that either. Not sure of correct syntax.
Any thoughts how to do this?
Thanks.