random_work
New Member
- Joined
- Apr 5, 2012
- Messages
- 5
Hi.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Im trying to sum the cell to the left and the cell 2 steps to the left in a excel, I have to paste this code to different places in sheet decided by a macro.<o></o>
I found the formula to be<o></o>
=INDIREKT(ADRESS(RAD();KOLUMN()-2;4;1))+INDIREKT(ADRESS(RAD();KOLUMN()-1;4;1))<o></o>
Simular in englich<o></o>
=INDIRECT(ADDRESS (ROW();COLUMN()-2;4;1))+INDIRECT(ADDRESS (ROW();COLUMN()-1;4;1))<o></o>
This formula works but my problem are that I have to past it in to different cell with a macro/VBA and then the vba refuses…<o></o>
Simplified the code are<o></o>
Sub test()<o></o>
Dim del(1 To 2) As String
Dim iCount As Integer<o></o>
iCount = 1
‘del(1) = "INDIREKT(ADRESS(RAD();KOLUMN()-2;4;1))+INDIREKT(ADRESS(RAD();KOLUMN()-1;4;1))"
del(1)=”INDIRECT(ADDRESS (ROW();COLUMN()-2;4;1))+INDIRECT(ADDRESS (ROW();COLUMN()-1;4;1))”
ActiveCell = "=" + del(iCount)
End Sub<o></o>
This giving me error and the macro don’t add the string to activecell but if I past it manually it works.<o></o>
Why? Howe do I fix it and do any one have a better solution? <o></o>
Im trying to sum the cell to the left and the cell 2 steps to the left in a excel, I have to paste this code to different places in sheet decided by a macro.<o></o>
I found the formula to be<o></o>
=INDIREKT(ADRESS(RAD();KOLUMN()-2;4;1))+INDIREKT(ADRESS(RAD();KOLUMN()-1;4;1))<o></o>
Simular in englich<o></o>
=INDIRECT(ADDRESS (ROW();COLUMN()-2;4;1))+INDIRECT(ADDRESS (ROW();COLUMN()-1;4;1))<o></o>
This formula works but my problem are that I have to past it in to different cell with a macro/VBA and then the vba refuses…<o></o>
Simplified the code are<o></o>
Sub test()<o></o>
Dim del(1 To 2) As String
Dim iCount As Integer<o></o>
iCount = 1
‘del(1) = "INDIREKT(ADRESS(RAD();KOLUMN()-2;4;1))+INDIREKT(ADRESS(RAD();KOLUMN()-1;4;1))"
del(1)=”INDIRECT(ADDRESS (ROW();COLUMN()-2;4;1))+INDIRECT(ADDRESS (ROW();COLUMN()-1;4;1))”
ActiveCell = "=" + del(iCount)
End Sub<o></o>
This giving me error and the macro don’t add the string to activecell but if I past it manually it works.<o></o>
Why? Howe do I fix it and do any one have a better solution? <o></o>