View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Finding Problems in Comma Separated List

This assumes that valid characters are upper and lower case letters, digits,
spaces, and commas:

Function validd(r As Range) As Boolean
v = r.Value
validd = True
For i = 1 To Len(v)
ch = Mid(v, i, 1)
If ch Like "[0-9a-zA-Z]" Or ch = " " Or ch = "," Then
Else
validd = False
Exit Function
End If
Next
End Function


UDFs are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To use the UDF from the normal Excel window, just enter it like a normal
Excel Function:

=validd(A1)

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about UDFs, see:

http://www.cpearson.com/excel/Writin...ionsInVBA.aspx


--
Gary''s Student - gsnu200825


"Daren" wrote:

Hello,

I have a comma separated list with codes that is set up as G01, G02, G03,
H01, Y02, B03, A06. There can be many many codes on each row, but they
should only be separated by commas and spaces but no other characters. Is
there a function I can use to show any unnecessary spaces and characters?

Thanks.