Performing a calculation on a range of cells and replacing contents

Crazy_Ivan

Board Regular
Joined
Oct 8, 2007
Messages
115
So I would like to select a range of cells or a single cell and perform a calculation on each individual cell and replace the contents of each individual cell with the outcome of the calculation.

The calculation will always be MULTIPLY BY 0.38444%

So for example, I select A1:D12, run the macro through a shortcut, then the original numbers in the range selected are all multiplied by 0.38444% and the answers, pasted as a value (or =original value * 0.38444%) fill each cell in the range.

Feels like a simple question.... is there a simple answer?!

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Put the 0.3844 into a cell, copy it & then select the cells to multiply & paste special multiply.
 
Upvote 0
If you need a macro select the cells you want to multiply & use
VBA Code:
Sub CrazyIvan()
   With Selection
      .Value = Evaluate("if(" & .Address & "="""",""""," & .Address & "*0.0038444)")
   End With
End Sub
This will only work on a contiguous range.
 
Upvote 0
Solution
If you need a macro select the cells you want to multiply & use
VBA Code:
Sub CrazyIvan()
   With Selection
      .Value = Evaluate("if(" & .Address & "="""",""""," & .Address & "*0.0038444)")
   End With
End Sub
This will only work on a contiguous range.

Ah perfect - the macro is just what I need.
It is shortcut so I can see a KPI very quickly in different data sets.

Thanks for your help!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,050
Messages
6,122,868
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