Custom formatting in excel to multiply

maria_b

New Member
Joined
Jan 6, 2015
Messages
4
Hi,

Is it possible to format cells to automatically multiply a input value by a fixed number and return the product in the same cell? Can this be done in Excel?

Kind regards,

Maria
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Things like Custom Formatting and Data Validation can only change the appearance of a cell, not the value.
You can use some Event Procedure VBA code to automatically multiply an entry.

Below is an example that will multiply any numeric entry in cells A1:C10 by 3.
Just right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this code in the resulting window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'   Check to see in entry is is pre-determined range
    If Not Intersect(Target, Range("A1:C10")) Is Nothing Then
'       Check to see if entry is numeric
        If IsNumeric(Target) Then
            Application.EnableEvents = False
'           Multiply entry by 3
            Target = Target * 3
            Application.EnableEvents = True
        End If
    End If
    
End Sub
Then try making any numeric entry in that range and watch what happens.
 
Upvote 0
Thanks Joe. If I have a number of ranges that I want to set up to automatically multiply a input value, can I do this by adding additional ranges on the third line of the syntax or do I have to run the syntax for each range?

Thanks for your help.

Kind regards,

Maria
 
Upvote 0
You should be able to set up multiple ranges in a single statement like this:
Code:
If Not Intersect(Target, Range("A1:C10, M1:P10, X1:Z10")) Is Nothing Then
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,684
Members
449,463
Latest member
Jojomen56

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