Calculate a total in the same cell as one of the values

MonsieurExcel

New Member
Joined
Oct 27, 2011
Messages
13
Hi there,

I'm trying to calculate an updated cost based on an updated exchange rate (example below)

I want to be able to multiply Cell A6 * Cell A2 but keep the solution in Cell A6. The same applies for Cell B6 * Cell B2 etc

I have thousands of Costs that need to be applied with the rate and want to keep them in their cells because the rates will change.

Usually, for example, in Cell A6 I could just use =12.214*A2 if it was a small range of values but because there are thousands of costs that's not practical.

Thank you for reading and apologies if I'm missing something really straightforward!!

AB
1raterate
20.890.90
3
4
5CostCost
612.21413.255
713.00913.294
812.89913.111
912.68713.244

<tbody>
</tbody>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
There is 2 solutions at your problem.

1. without VBA : use your other column for making your calcul : D6=A$2*A6 and copy/paste your value back in column A

2. with VBA : a macro like the following that would need to be put in a loop

Code:
Range("A6") = Range("A6") * Range("A2")

If you want the solution #2 , I would need to know kind of range you have.
 
Upvote 0
Thank you - sorry, I should have mentioned that I still want to see the original value in there, if that's at all possible?

So, something like =12.214*A$2
=13.009*A$2
=12.899*A$2
=12.687*A$2

I'm wondering if it's possible to copy that sort of "formula" down 1000 rows and across 30 columns?

I do appreciate your reply - also, I'm terrible at VBA although I'd love to be at least competent in it!

Thanks again
 
Last edited:
Upvote 0
1. If you want to multiply a number or range by a factor, put the factor into a cell such as B2. Copy the cell B2. Select a cell or Range then Paste Paste Special Multiply.

2. If one needs to do this in the future, the costs could be linked to the exchange factor (a cell or a named factor). When the exchange rate changes, just edit one cell or named factor.
 
Upvote 0
The only way that you can do that is in VBA because Excel don't have that kind of self-reference available.

So here is a Macro to do it

Code:
Sub example()
Dim r As Range
Application.ScreenUpdating = False
For Each r In Range("A6:P11")
    r.FormulaR1C1 = "=" & r.Value & "*R2C[0]"
Next
Application.ScreenUpdating = True
End Sub

To open the VBA windows, use ALT+F11. Copy that code in a new module. Press F5 to use it.

I HIGHLY suggest you to use a copy of your original file to use VBA.
 
Upvote 0
I forgot to say that you will need to adjust the range for the loop from A6:P11 to exactly what you need.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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