Automatic Multiplication

mickyd67

Board Regular
Joined
Jul 13, 2011
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi all - I couldn't find anything on Google so coming to somewhere much better :)

I am looking to understand if this is possible:

I enter the number 10 (let's say) into Cell A1 and that automatically returns a value of 50, because the cell is set up to multiply any number you type x5.

I'm trying to avoid using the formula of 10*5 because I have to adjust the number 10 multiple times across the file but I want all the cells to multiply by 5 when I update them, it's just taking ages to go in and adjust each formula.

Hope that makes sense...
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You can use VBA code to automatically multiply any manual entry you make by 5.
If you let us know exactly what range of cells you want this behavior to apply to, we can help you come up with that VBA code.
 
Upvote 0
Hi Joe - many thanks for the reply, and the offer to help.

I would have 2 ranges it'd would apply to (but I assume I can add more if I know the VBA code and how it works)

In this instance:

Multiplication value: Cell A2 / Applies to Range: B2 to M31 (basically 12 months across, x30 rows)

And also:

Multiplication value: Cell A33 / Range: B33 to M62

Hope that is what you're after.
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste the following VBA code in the VB Editor window that pops up:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng1 As Range
    Dim rng2 As Range
    Dim cell As Range
    
'   See if any cells updated in first range
    Set rng1 = Intersect(Target, Range("B2:M31"))
    
'   Update cells if value updated in rng1
    If Not rng1 Is Nothing Then
        Application.EnableEvents = False
        For Each cell In rng1
            cell.Value = cell.Value * Range("A2").Value
        Next cell
        Application.EnableEvents = True
    End If
    
'   See if any cells updated in first range
    Set rng2 = Intersect(Target, Range("B33:M62"))
    
'   Update cells if value updated in rng1
    If Not rng2 Is Nothing Then
        Application.EnableEvents = False
        For Each cell In rng2
            cell.Value = cell.Value * Range("A3").Value
        Next cell
        Application.EnableEvents = True
    End If
 
End Sub
This code will automatically run/update when you manually enter values in B2:M31 or B33:M62.
 
Upvote 0
Solution
That works a treat - many thanks Joe.

The task I am doing is still super painful mind you so I am going to start a new thread to see if the Solver function can help.
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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