View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default end number keeps changing to '0'

The only solution I havefound is to:

Format cells as text and then enter the data (ay in Column A)

In column B put =TEXT(A1,"0000-0000-0000-0000") and copy down

At some point. copy/paste special=values

OR

Place this code in worksheet (right click on tab, view code and copy and
paste)

Change Range("A:A") to suit

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo wsexit:

Set isect = Application.Intersect(Range("A:A"), Target)
If isect Is Nothing Then
' MsgBox "Ranges do not intersect"
Else
Target.Value = Format(Target.Value, "0000-0000-0000-0000")
End If
wsexit:
Application.EnableEvents = True
End Sub




"Shivaraj" wrote:

Hello,

I am trying to keep trackof credit card numbers, i put in a custom formating
that looks like this: ####-####-####-#### so i can just type the numbers in
without having to type '-'.

The only problem is that is always turns the last number into a '0' zero.

for instance if the number is:
4519-3589-2000-1875

the formula changes the number to this:
4519-3589-2000-1870

Thank you,

shivaraj