Having a # and % in the same cell

willyharris

New Member
Joined
Apr 12, 2013
Messages
1
Hello,

I want to add a number and percentage to one cell. I want the user to be able to enter the number then it would automatically calculate the percentage based on a different cell. If it could look like 20(50%) that would be ideal.

So if the user enters '100' in A1, then enters '50' in B1, I would like B1 to keep the 50 and automatically compute the percentage of 100/50 as well. So B1 would look like 50(50%).

THANKS!


<colgroup><col span="2" width="64"></colgroup><tbody>
</tbody>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
Welcome to the Board.

Sounds like you're after a simple Worksheet_Change event...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$B$1" Then Target = Target.Value & Format(Target.Value / Range("A1"), "(0%)")
Application.EnableEvents = True
End Sub
 
Upvote 0

sergioMabres

Well-known Member
Joined
Feb 24, 2013
Messages
946
In the same cell I do not know but in a third cell I do know how to do this, probably is not what you are looking for, but to change the value of the cell you have just input a value requires monitoring the event (Worksheet_Change) and working with the Target
For instance change the value to a string with what you want '50(50%)

Code:
Private Sub Worksheet_Change(ByVal Target as Range)      
    Target.Font.ColorIndex = 5
    ' Use target to read and write formulas and values 
End Sub

You can find information at http://www.mrexcel.com/forum/excel-questions/21136-cell-change-event.html
regards
Sergio
 
Upvote 0

Forum statistics

Threads
1,195,848
Messages
6,011,948
Members
441,657
Latest member
Diupsy

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
Top