View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
amirstal[_2_] amirstal[_2_] is offline
external usenet poster
 
Posts: 18
Default Make Excel know 1M is 1,000,000

On Jun 20, 12:28 pm, "Bob Phillips" wrote:
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit
Application.EnableEvents = False

With Target
If LCase(Right$(.Value2, 1)) = "m" And _
IsNumeric(Left$(.Value2, Len(.Value2) - 1)) Then
.Value = Left$(.Value2, Len(.Value2) - 1) * 1000000
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"amirstal" wrote in message

oups.com...

On Jun 20, 11:50 am, Tom Ogilvy
wrote:
Tools=Autocorrect options . . .


--
Regards,
Tom Ogilvy


"amirstal" wrote:
How can I make excel know that when I type 1M in a cell the number
1,000,000 should appear in that cell (2M will appear as 2,000,000
etc)?


Thanks,


Amir


Thanks. But is there a way to make a rule so I won't have to enter all
manually.
For example, excel should know that 1.2m means 1200000 and 3.873m is
3873000...


This is great. Thanks very much.
However, when I try to use with the negative sign, it does not work
for example: if I type -0.3m in order to get -300000, I am getting an
error message saying "The formula you typed contains an error."