TheLSD
TheLSD

Reputation: 47

Automatically multiple value inputted from a specific cell

Can I make the value that I input automatically on a cell multiplied by a value on a cell? In the picture below, when I type "1" on "Jan" and press enter, the value automatically turns to "1500" by multiplying "Jan" with "Price". If I enter "3" on "Jan", then it becomes "4500"

Thank you!

the problem and expected outcome

Upvotes: 0

Views: 124

Answers (1)

To be honest, I think using a secondary column would be the best, but anyways, you can create an UDF in VBA to get this. I choose this approach instead of playing with events because using events sometimes give headaches managing them.

So my UDF is named PRICE but you can change it to something sorter and it requirres just the input number (1 or 3 in your example):

Public Function PRICE(ByVal vValue As Integer) As Double
PRICE = vValue * Application.ThisCell.Offset(0, -1).Value
End Function

enter image description here

enter image description here

This UDF will take always the previous cell in same row and will multiply by your input (1 or 3 or whatever)

Upvotes: 1

Related Questions