multiply multiple cells by a single cell but retain formula

sheetspread

Well-known Member
Joined
Sep 19, 2005
Messages
5,160
Lets say I want to highlight any cell or cells and multiply them all by the value in cell I7. Paste special multiply will leave me with the correct number but not the formula.

I7= 1.05

Say A4 = 100

Showing 105 is good but in the cell formula I'd like =100*1.05 to appear

Is there a VBA code or other technique that works?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi Sheet, you could use something like:
Code:
Range("A4").Formula = "=" & Range("A4").Value & "*" & Range("I7").Value
 
Upvote 0
Or something like this?

Code:
Sub Macro1()
Dim cell As Range
iMultipler = Range("I7").Value
For Each cell In Selection.Cells
    icell = cell.Value
    Debug.Print icell
    cell.Formula = "=" & icell & "*" & iMultipler
Next
End Sub

Lee
 
Upvote 0
Thanks guys!

roundabout, if I wish to modify the macro so that *I7 appears instead of *1.05, what should I type?
 
Upvote 0
Forgive the bump,


Sub Macro1()
Dim cell As Range
iMultipler = Range("I7").Value
For Each cell In Selection.Cells
icell = cell.Value
Debug.Print icell
cell.Formula = "=" & icell & "*" & iMultipler
Next
End Sub

works great. As a variation, what should be done to change iMultipler = Range("I7").Value so that the result is *I7 instead of *(numerical content of I7)?

I tried iMultipler = "I7".cell and other layman inferences but no luck...........
 
Upvote 0
Code:
cell.Formula = "=" & icell & "*" & Range("I7").Address(,,,True)
I gave it in this format rather than hard coding the I7 in case you want to use a different cell.

It might be easier in the long run if you had a helper column rather than replacing constant values with a formula.
 
Upvote 0
Ah, brilliant Mike. Thank you. I'm actually using helper columns in other tabs that link to this summary sheet, and wanted a quick, different way to add one last variable adjustment.
 
Upvote 0
Hi everyone,
I hope I'm not committing anything against the rules by replying to this fairly old thread - it's just that the it basically describes my question - except I would need also the original formulas to stay and not be changed into values. I'm really bad at explaining, so please let me give an example...

[background: I have a fairly large table with formulas using input data from a different sheet and I would like to be able to multiply these by a "variable/adjustable" value without changing the original formulas]

simple example:
in C4 I have the following formula =Sheet2!A1*Sheet2!A2 (let's say the result is 40)
in C5 I have the following formula =Sheet2!A1+Sheet2!A2 (let's say the result is 13)
in A4 I have a "multiplier" (a number, let's say 10)

is there any way to create this (in C4, C5...): =A4*(Sheet2!A1*Sheet2!A2) and =A4*(Sheet2!A1+Sheet2!A2) without having to manually change the formulas (I do have A LOT)? Hope this makes sense.

It seems like something that *should* be easy to do but somehow I can't figure out how.

Thank you very much in advance.

K.
 
Upvote 0
Select the cells you wish to change and run this:

Code:
Sub insertmultiplier()
For Each cell In Selection
cell.Formula = "=a4*(" & Mid(cell.Formula, 2, 255) & ")"
Next cell
End Sub

If it's easier use F5 (goto) to select special cells with formulas only first.
 
Upvote 0

Forum statistics

Threads
1,215,052
Messages
6,122,878
Members
449,097
Latest member
dbomb1414

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