Automatic adding in a single cell w/o equal sign

J

jacky

how do I automatically in a single cell input 5+5 without the equal sign and
have a total come up
 
G

Gary''s Student

Let's use cell B9 as an example. Insert the following event macro in the
worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Set r = Range("B9")
v = r.Value
If Intersect(r, Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
r.Value = Evaluate(v)
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
J

jacky

Thank you for the information Gary, however; I need to do this in several
cells where i am able to add in the individual cell. Can you help
 
J

jacky

I just want capability to be able to add numbers in each cell using the
keyboard for example:

5+5 then enter button will give me 10
I would like to do that in each cell.
 
J

jacky

I want to be able to add several numbers in each cell w/o equal sign.

5+5+6 and have the total come up when i press enter on the keyboard.
thanks
 
J

John

Hi Jacky
Maybe this will help if I understand your question.
If you use a lot your numeric keypad for your calculations, start with a + on
the keypad instead of the = sign, e.g. +5+5-5, +5*5.etc. The + sign is handy
right beside your numbers.
You should know that in the future, Microsoft will stop using that function and
you will need to use the = sign.
Its a backward compatibility with Lotus123 and is no longer used.

HTH
John
 
G

Gary''s Student

Here is a small variation of the code I posted before. Be sure you delete
the old code before installing this version:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Set r = Target
v = r.Value
Application.EnableEvents = False
r.Value = Evaluate(v)
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top