Active VBA - Multiply input with data in cell range

Masimo85

New Member
Joined
Jun 5, 2020
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi,

So I've tried to work with an active macro here to multiply input into Cell range A11-A18 with the cell value of A5

However, I need the same macro to do it for all cells in the same numeric value but different Alphabetic value if that makes sense.

Basically, I need it to do the same for row B11-B18 with the cell value of B5 - etc for a wide range in the Alphabetic value.



Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E11:E18")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value * Range("E5").Value
Application.EnableEvents = True
End Sub

Can anyone help me here?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
What should trigger this code to run?
A manual entry into row 5?
 
Upvote 0
Right now it works when I input data into rows A11-A18 - and then it Multiply the entry with value of A5.
 
Upvote 0
Try this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.CountLarge > 1 Then Exit Sub
    
    If Intersect(Target, Rows("11:18")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    Target.Value = Target.Value * Cells(5, Target.Column).Value
    Application.EnableEvents = True
    
End Sub
 
Upvote 0
Try this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.CountLarge > 1 Then Exit Sub
   
    If Intersect(Target, Rows("11:18")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    Target.Value = Target.Value * Cells(5, Target.Column).Value
    Application.EnableEvents = True
   
End Sub

That works, thank you Joe4.
 
Upvote 0
You are welcome.
 
Upvote 0
Hei Joe4 - or anyone else able to help with this one again.

So everything worked flawlessly, until i did some formatting of the cells I used.
I thought that it was only visuell effects that would change the cells, however the "Active Macro" to multiply the input with Cell 5 is not working anymore?

I dno if this works, however heres a smaller clipout of the Sheet - its in norwegian, so disregard the text ;)

Prisbase Element - TEST.xlsm
ABCD
1Post123
2Prosjekt Nummer
3Element no.
4Antall vinduer
5Antall personer2
6H
7B
8Areal000
9
10Forbruk i timer:
11Stenderverk1,00
12Gips1,00
13Vindu1,00
14Lekt1,00
15Kledning1,00
16Isolasjon1,00
17Plast1,00
18Inv. Lekter1,00
MAL - VEGG
Cell Formulas
RangeFormula
B8:D8B8=B7*B6


1620117105697.png
 
Upvote 0
I thought that it was only visuell effects that would change the cells, however the "Active Macro" to multiply the input with Cell 5 is not working anymore?
In the example you posted, their is nothing in cell C5. So, there is nothing to multiply by.

Can you post an actual example that is not working, and walk us through the steps that don't work (i.e. what number are you placing in what cell)?
 
Upvote 0
In the example you posted, their is nothing in cell C5. So, there is nothing to multiply by.

Can you post an actual example that is not working, and walk us through the steps that don't work (i.e. what number are you placing in what cell)?
Hei Joe4 ..

Well the macro is working by multiplying the input data in cell 5 of the current Target.Column.

I belive thats how we made it work in the Macro?
Its not bound to C5.. ?

As Ive done in the current example the input is in B5 and the row B11-B18 should be multiplied by "2"?
 
Upvote 0
Well the macro is working by multiplying the input data in cell 5 of the current Target.Column.

I belive thats how we made it work in the Macro?
Its not bound to C5.. ?

As Ive done in the current example the input is in B5 and the row B11-B18 should be multiplied by "2"?
The way the code is written, any time you manually enter a value in any one cell in rows 11 through 18, it will automatically multiply that number by the value in row 5 of that same column.
So, if if make an entry in cell B14, it will multiply it by the value in cell B5.
It is my understanding that is what you want to happen, right?

If there is some situation that is not working out for you, please walk us through an example, in detail, step-by-step.
What value are you entering in what cell?
What is the value in row 5 of that same column?
Is it not multiplying the values together for you?
 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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