#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Custom Format

I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it returns
100-2021-2448-0046-00

Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 694
Default Custom Format

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Custom Format

That would be a good reason that it isn't working, then. How do I do it in
text with the format that I want?


"John" wrote:

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 694
Default Custom Format

Hi Select the cells you want and format it as text, this must be done before
you enter your numbers.
Also you can type a Apostrophe before your numbers like this '123456 the
apostrophe will disappear in the cell when you push enter.
HTH
John

"Difficult1" wrote in message
...
That would be a good reason that it isn't working, then. How do I do it in
text with the format that I want?


"John" wrote:

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something
other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Custom Format

You can use an event macro that actually changes the value of the cell by
inserting the extra 0's and dashes.

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code. Paste this into the code window that just opened:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myTempVal As Variant

On Error GoTo ErrHandler:

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If IsNumeric(Target.Value) = False Then
Exit Sub
End If

myTempVal = CDec(Target.Value)
Application.EnableEvents = False
Target.Value = Format(myTempVal, "000-0000-0000-0000-00")

ErrHandler:
Application.EnableEvents = True

End Sub

(I looked for any change in column A. Modify that if you need to.)

Now back to excel.

Format the range that gets the values as Text (format|cells|number tab|text
category).

Type some numbers in that range and test it out.

Difficult1 wrote:

That would be a good reason that it isn't working, then. How do I do it in
text with the format that I want?

"John" wrote:

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?




--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 694
Default Custom Format

HI again
Sorry, disregard my last post,I forgot about the dash formatting.
in Text mode you would have to type them in yourself.
John
"John" wrote in message
...
Hi Select the cells you want and format it as text, this must be done
before you enter your numbers.
Also you can type a Apostrophe before your numbers like this '123456 the
apostrophe will disappear in the cell when you push enter.
HTH
John

"Difficult1" wrote in message
...
That would be a good reason that it isn't working, then. How do I do it
in
text with the format that I want?


"John" wrote:

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something
other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Custom Format

tried it, and it works perfect! Thank you!

"Dave Peterson" wrote:

You can use an event macro that actually changes the value of the cell by
inserting the extra 0's and dashes.

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code. Paste this into the code window that just opened:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myTempVal As Variant

On Error GoTo ErrHandler:

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If IsNumeric(Target.Value) = False Then
Exit Sub
End If

myTempVal = CDec(Target.Value)
Application.EnableEvents = False
Target.Value = Format(myTempVal, "000-0000-0000-0000-00")

ErrHandler:
Application.EnableEvents = True

End Sub

(I looked for any change in column A. Modify that if you need to.)

Now back to excel.

Format the range that gets the values as Text (format|cells|number tab|text
category).

Type some numbers in that range and test it out.

Difficult1 wrote:

That would be a good reason that it isn't working, then. How do I do it in
text with the format that I want?

"John" wrote:

Hi
Excel limits is 15 digits unless you format your numbers in Text.
HTH
John
"Difficult1" wrote in message
...
I am trying to enter a custom format that will enable the user to enter
numbers without symbols... such as a phone number... but, the format I
need
is:

xxx-xxxx-xxxx-xxxx-xx

I have tried the custom format and it works, until I enter something other
than 0's for the last two digits. If I enter 100-2021-2448-0046-95 it
returns
100-2021-2448-0046-00

Any thoughts?



--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format Cell as custom type but data doesn't display like I custom. ToMMie Excel Discussion (Misc queries) 6 September 11th 08 08:31 AM
Excel 2003. Custom format gets replaced by Special format. jasper New Users to Excel 0 September 1st 08 03:46 AM
ignore auto format after applying a custom format?? jigglepop Excel Discussion (Misc queries) 0 April 2nd 08 04:17 PM
Custom Cell format to mimic time format [email protected] Excel Discussion (Misc queries) 6 November 7th 06 09:17 PM
how do I add phone number format as a permanent custom format? frustratedagain Excel Discussion (Misc queries) 3 February 4th 06 03:52 AM


All times are GMT +1. The time now is 08:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"