Help with Calculating Using Macro Pleaseeeeeeee

Y

Yossy

I have a workbook with multiple worksheet. For each worksheet in the Wkbook I
want the following to Calculate.

First C162:M163 - Copy content and paste the content as Value
Second For each cell C165:M252 Calculate (C18/c$162)*C$163,
(d19/d$162)*d$163 and so on till (M161/m$162)*m$163
then for each cell C18:M161 Calculate (c18/c$162)*c$13, (d19/d$162)*d$13,
and so on till (M161/m$162)*m$13.
lastly add Cell C18:C161, D18:D161 until M18:M161 and clear content in
C163:M163.

- Note please the calculation is a sample calculation for C18 and d19. I
want the calculation to affect all cells within range specified C18:M161 and
C165:M252, that is why I made row c$162, rowC$13 and Row C$163 absolute.

Please help me in any way possible, I really appreciate all support. Thanks
 
J

Joel

Try the code below. I'm using formulas. You may want to copy the formulas
and use PasteSpecial values. I think there is a problem with clearing
"C163:M163" because these values are used as part of the calculation for
other cells. first try the code without the clearcontents to see if
everything works. then decide if you need to paste values before clearing
the cells.


Range("C162:M163").Copy
Range("C162:M163").PasteSpecial _
Paste:=xlPasteValues

Range("C165").Formula = "=(C18/C$162)*C$163"
Range("C165").Copy Destination:=Range("C165:M252")

Range("C164").Formula = "=Sum(C18:C161)"
Range("C164").Copy Destination:=Range("D164:M164")

Range("C163:M163").ClearContents
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top