Hi Jim,
Thank you for the code. I'll have to take closer look at it. I dont want the
user use a input box, but enter directly into the cell. So i'll poke around
with it.
I appreciate your quick reply.
Stefan
Jim Cone wrote:
Stefan,
The following uses the selection change event, maybe it
can get you started...
Jim Cone
San Francisco, USA
'--------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strCardNum As String
Dim strCaption As String
strCaption = "Process Card Number"
TryAgain:
If Target.Address = "$C$25" Then
strCardNum = VBA.InputBox("Enter the card number as..." & vbCr & _
"First 2 digits and last 4 digits: 12 3456" & vbCr & _
"or" & vbCr & _
"All 16 digits: 1234 5678 9101 1121", strCaption)
End If
If Len(strCardNum) = 0 Then
Exit Sub
ElseIf Len(strCardNum) = 7 Then
'Verify number is valid then
Range("C25").Value = strCardNum
ElseIf Len(strCardNum) = 19 Then
'Verify number is valid then
Range("C25").Value = strCardNum
Else
strCaption = "Please try again"
GoTo TryAgain
End If
End Sub
'---------------------------
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
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If bDisableEvents Then Exit Sub
If Intersect(Target, Me.Range("C28:H28")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
bDisableEvents = True
With Me
.Range("28:28").Insert
.Range("29:29").Copy Range("28:28")
.Range("28:28").ClearContents
.Range("D29").Select
End With
bDisableEvents = False
End Sub
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200507/1