ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error trapping (https://www.excelbanter.com/excel-programming/366067-error-trapping.html)

[email protected]

Error trapping
 
Hi,

I have the below coding, it all works however I need to be able to put
a variable figure on the range B17. i.e. some cards have 16 digits,
some have 19. So I need to instruct the sheet to return a message when
there less or more numbers than this??

Can anyone help?

Thanks in advance.

Cragcito



Public Sub Pre_Checks_Before_Mail()

If Range("B13").Value = "" Then
MsgBox "You have not entered The Account Number."
Exit Sub
End If


If Range("B14").Value = "" Then
MsgBox "You have not entered The Customer Number."
Exit Sub
End If

If Range("B16").Value = "" Then
MsgBox "You have not entered Card Security Number."
Exit Sub
End If

If Range("B17").Value = "" Then
MsgBox "Please enter Exact Name on Card."
Exit Sub
End If

''If Range("B17").Value <= "****************" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If

If Range("B19").Value = Range("E15").Value Then
MsgBox "Card is to NEW"
Exit Sub
End If

If Range("B20").Value = 0 Then
MsgBox "Expiry date is needed"
Exit Sub
End If

If Range("B20").Value <= Range("E15").Value Then
MsgBox "Card has EXPIRED"
Exit Sub
End If

If Range("B18").Value < 0 Then
MsgBox "We can process a card payment without a card
number?!?!?!?!."
Exit Sub
End If

If Range("B22").Value = 0 Then
MsgBox "We MUST have a phone number to contact customer"
Exit Sub
End If

If Range("B23").Value = "" Then
MsgBox "Card BILLING address is required"
Exit Sub
End If

If Range("B8").Value 0 Then
MsgBox "Is customer aware of 2% surcharge??"
Exit Sub
End If

'' If Range("B17").Value <= "???????????????" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If


Nick Hodge

Error trapping
 
Craig

Sub test()
If Len(Range("A1").Value) < 16 Then
MsgBox "Must be more than 16 chars"
End If
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


wrote in message
oups.com...
Hi,

I have the below coding, it all works however I need to be able to put
a variable figure on the range B17. i.e. some cards have 16 digits,
some have 19. So I need to instruct the sheet to return a message when
there less or more numbers than this??

Can anyone help?

Thanks in advance.

Cragcito



Public Sub Pre_Checks_Before_Mail()

If Range("B13").Value = "" Then
MsgBox "You have not entered The Account Number."
Exit Sub
End If


If Range("B14").Value = "" Then
MsgBox "You have not entered The Customer Number."
Exit Sub
End If

If Range("B16").Value = "" Then
MsgBox "You have not entered Card Security Number."
Exit Sub
End If

If Range("B17").Value = "" Then
MsgBox "Please enter Exact Name on Card."
Exit Sub
End If

''If Range("B17").Value <= "****************" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If

If Range("B19").Value = Range("E15").Value Then
MsgBox "Card is to NEW"
Exit Sub
End If

If Range("B20").Value = 0 Then
MsgBox "Expiry date is needed"
Exit Sub
End If

If Range("B20").Value <= Range("E15").Value Then
MsgBox "Card has EXPIRED"
Exit Sub
End If

If Range("B18").Value < 0 Then
MsgBox "We can process a card payment without a card
number?!?!?!?!."
Exit Sub
End If

If Range("B22").Value = 0 Then
MsgBox "We MUST have a phone number to contact customer"
Exit Sub
End If

If Range("B23").Value = "" Then
MsgBox "Card BILLING address is required"
Exit Sub
End If

If Range("B8").Value 0 Then
MsgBox "Is customer aware of 2% surcharge??"
Exit Sub
End If

'' If Range("B17").Value <= "???????????????" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If




Andrew Taylor

Error trapping
 
If Len(Range("B17").Value) < 16 Then
MsgBox "Card Number must be at least 16 digits."
... etc

Andrew

wrote:
Hi,

I have the below coding, it all works however I need to be able to put
a variable figure on the range B17. i.e. some cards have 16 digits,
some have 19. So I need to instruct the sheet to return a message when
there less or more numbers than this??

Can anyone help?

Thanks in advance.

Cragcito



Public Sub Pre_Checks_Before_Mail()

If Range("B13").Value = "" Then
MsgBox "You have not entered The Account Number."
Exit Sub
End If


If Range("B14").Value = "" Then
MsgBox "You have not entered The Customer Number."
Exit Sub
End If

If Range("B16").Value = "" Then
MsgBox "You have not entered Card Security Number."
Exit Sub
End If

If Range("B17").Value = "" Then
MsgBox "Please enter Exact Name on Card."
Exit Sub
End If

''If Range("B17").Value <= "****************" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If

If Range("B19").Value = Range("E15").Value Then
MsgBox "Card is to NEW"
Exit Sub
End If

If Range("B20").Value = 0 Then
MsgBox "Expiry date is needed"
Exit Sub
End If

If Range("B20").Value <= Range("E15").Value Then
MsgBox "Card has EXPIRED"
Exit Sub
End If

If Range("B18").Value < 0 Then
MsgBox "We can process a card payment without a card
number?!?!?!?!."
Exit Sub
End If

If Range("B22").Value = 0 Then
MsgBox "We MUST have a phone number to contact customer"
Exit Sub
End If

If Range("B23").Value = "" Then
MsgBox "Card BILLING address is required"
Exit Sub
End If

If Range("B8").Value 0 Then
MsgBox "Is customer aware of 2% surcharge??"
Exit Sub
End If

'' If Range("B17").Value <= "???????????????" Then
'' MsgBox "Card Number must be at least 16 digits."
'' Exit Sub
''End If




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com