Reference a Cell in Formula from VBA

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Hello,

I'm just having troubles with referencing to a cell with a formula.

I currently have a formula that needs to be updated in accordance with the last cell and varying columns.

Basically, from http://www.mrexcel.com/forum/showthread.php?t=563695&page=2
I want to be able to do this without an error:
Code:
    For j = Range("D1").Column To Range("Q1").Column
        Cells(LRbal1 - 2, j).Formula = "=SUM(" & Cells(8, j) & ":" & Cells(LRbal1 - 4, j)
    Next j

As you can see from the code, it is looping through the columns and it is trying to add up from row 8 to the last row of data like
=SUM(D8:D1234)
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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