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
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,113,989
Messages
5,545,355
Members
410,679
Latest member
rolandbianco
Top