Thread: Checking
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] nathaniel.polky@gmail.com is offline
external usenet poster
 
Posts: 1
Default Checking

I can't figure out the syntax to my problem. I have a column that
varies in length for each use. It contains product descriptions and
once entered in excel, it will be uploaded into our inventory
management system. The system has a few constraints for a Product
Description:

1 - Product Descriptions can have no more than 32 characters (I
protected against that with cell validation)
2 - Product Descriptions cannot have the characters - commas, double
quotes and ampersands

I have a macro for when a user enters a value cell by cell, but I can't
seem to tweak it to force the user to change those characters if they
copied a range of cells into the column. Any thoughts?

Thanks

Nathaniel W. Polky



'My Current Macro
Private Sub Worksheet_Change(ByVal Target As Range)
Dim blnIsOk As Boolean

blnIsOk = True
If Target.Column = 7 Then
If InStr(1, Target.Value, """") Then
blnIsOk = False
ElseIf InStr(1, Target.Value, ",") Then
blnIsOk = False
ElseIf InStr(1, Target.Value, "&") Then
blnIsOk = False
End If
End If

If Not blnIsOk Then
MsgBox "Commas, double quotes, and ampersands (the & symbol)
are not allowed in product descriptions. Please refer to the Product
Description Policy. Thank You."
Application.Undo
End If

End Sub