Help filling cells via a macro

Dulock

New Member
Joined
Sep 24, 2006
Messages
1
Alright, so I've got 32 lines that need to be updated weekly...so I want a macro that will go down the line and subtract all the previous weeks from the now current total.

What I don't understand and cannot figure out how to even word properly to find the answers is, how do I reference the cell? Obviously "Dx" is not going to work.

So please, how do I change (in this example) D, T, B, and C to reference the proper excel columns?

Dim x As Integer

For x = 4 To 35
Dx = (Tx - sum(Bx:Cx))

Next x
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

Something like this maybe:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> foo()
    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
        <SPAN style="color:#00007F">For</SPAN> i = 2 <SPAN style="color:#00007F">To</SPAN> 35
            Range("D" & i) = Range("T" & i) - _
                Application.WorksheetFunction.Sum(Range("C" & i & ":" & "B" & i))
        <SPAN style="color:#00007F">Next</SPAN> i
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 

Forum statistics

Threads
1,141,022
Messages
5,703,793
Members
421,318
Latest member
cg_cartoonexcel

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
Top