View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default ccard 6 or 16 digits

Copied the wrong line from stefans post. The "X" s/b "#"

Try:
[Ccard].Value = Application.Text([Ccard].Value, "#### #### #### ####")

"PaulD" wrote:

"stefan via OfficeKB.com" wrote in message
...
:
: Hi,
: I have cell 'C25' or range CCard in which the user may enter the first 2
and
: lst 4 digits of a credit card or a full 16 digit card number.
: Apparently it seems to be the best way to avoid excels "15-digit rule" to
to
: a macro in a worksheet change module.
: What i'd like to accomplish is that if the user inputs the 2/4 numbers the
: result is 54xx xxxx xxxx 3210 and if the user inputs the full number 16
: digits it results in 5411 1111 1111 3210. I cant figure out how i can
: incorporate this in my existing worksheet change event which is at the end
of
: this post.
: Thank you for your help.
:
: Stefan

This will do a basic check of the range CCard and format the cell
accordingly

Sub FormatCcard()
If IsNumeric([Ccard].Value) Then
If [Ccard].Formula Like "######" Then
[Ccard].NumberFormat = "##xx xxxx xxxx ####"
ElseIf [Ccard].Formula Like "################" Then
[Ccard].NumberFormat = "#### #### #### ####"
Else
MsgBox "Invalid Number"
End If
Else
MsgBox "Not a Number"
End If
End Sub

Paul D