Current cell formula and and vba string error

random_work

New Member
Joined
Apr 5, 2012
Messages
5
Hi.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
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:p></o:p>
I found the formula to be<o:p></o:p>
=INDIREKT(ADRESS(RAD();KOLUMN()-2;4;1))+INDIREKT(ADRESS(RAD();KOLUMN()-1;4;1))<o:p></o:p>
Simular in englich<o:p></o:p>
=INDIRECT(ADDRESS (ROW();COLUMN()-2;4;1))+INDIRECT(ADDRESS (ROW();COLUMN()-1;4;1))<o:p></o:p>
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:p></o:p>
Simplified the code are<o:p></o:p>
Sub test()<o:p></o:p>
Dim del(1 To 2) As String
Dim iCount As Integer<o:p></o:p>
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:p></o:p>
This giving me error and the macro don’t add the string to activecell but if I past it manually it works.<o:p></o:p>
Why? Howe do I fix it and do any one have a better solution? <o:p></o:p>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,250
Messages
6,171,036
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top