PC Review


Reply
Thread Tools Rate Thread

Checking for Invalid filename characters

 
 
=?Utf-8?B?Sm9obiBLZWl0aA==?=
Guest
Posts: n/a
 
      7th May 2007
I am attempting to create a Data Validation formula to test an input cell to
make sure that it can be used to automatically assign a file name.

I tried putting the Data Validation "custom" formula attached to cell B2,
but all text comes back as invalid.
InStr(B2,"?"&Chr(34)&"/\<>*|:")=0

Any ideas on why this fails?

I.E.
" used here to show the string limits... not part of the actual string,
although Chr(34) would be an invalid filename character in the InStr above.
"Test" in the cell SHOULD be valid
"Test<1>" SHOULD NOT be valid
--
Regards,
John
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFzb24gTW9yaW4=?=
Guest
Posts: n/a
 
      8th May 2007
Hmmm....I couldn't get Validation to work with this huge formula, so I just
placed it in a cell and referenced the formula cell:

Put this in a cell (say E1):

=SUMPRODUCT(--(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))={34,42,47,58,60,62,63,92,124}))=0

Now in your Validation cell (formula assumes A1), choose Allow:Custom and in
Formula put:

=E1

HTH
Jason
Atlanta, GA


"John Keith" wrote:

> I am attempting to create a Data Validation formula to test an input cell to
> make sure that it can be used to automatically assign a file name.
>
> I tried putting the Data Validation "custom" formula attached to cell B2,
> but all text comes back as invalid.
> InStr(B2,"?"&Chr(34)&"/\<>*|:")=0
>
> Any ideas on why this fails?
>
> I.E.
> " used here to show the string limits... not part of the actual string,
> although Chr(34) would be an invalid filename character in the InStr above.
> "Test" in the cell SHOULD be valid
> "Test<1>" SHOULD NOT be valid
> --
> Regards,
> John

 
Reply With Quote
 
=?Utf-8?B?Sm9obiBLZWl0aA==?=
Guest
Posts: n/a
 
      8th May 2007
Thanks for the reply.

That is a slick formula!
At first I wasnt sure If your responce was to "my" question

I tried it and it does work. I think the DataValidation does not allow
array formulas (or perhaps it was the Indirect reference)

However I wanted to have a formula that would be easier for others to
understand & maintain later, so I ended up going with a direct formula which
I used a macro to assign (because paste wasn't allowed into the formula box)

sDV = "=AND(ISERROR(FIND(""?"",B2)),ISERROR(FIND(CHAR(34),B2))," & _
"ISERROR(FIND(""/"",B2)),ISERROR(FIND(""\"",B2))," & _
"ISERROR(FIND(""<"",B2)),ISERROR(FIND("">"",B2))," & _

"ISERROR(FIND(""*"",B2)),ISERROR(FIND(""|"",B2)),ISERROR(FIND("":"",B2)))"

--- To bad the Find() does not simply return 0 when the text is not found

Assigned using the
.validation.add method ... Formula1:=sDV

--
Regards,
John


"Jason Morin" wrote:

> Hmmm....I couldn't get Validation to work with this huge formula, so I just
> placed it in a cell and referenced the formula cell:
>
> Put this in a cell (say E1):
>
> =SUMPRODUCT(--(CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))={34,42,47,58,60,62,63,92,124}))=0
>
> Now in your Validation cell (formula assumes A1), choose Allow:Custom and in
> Formula put:
>
> =E1
>
> HTH
> Jason
> Atlanta, GA
>
>
> "John Keith" wrote:
>
> > I am attempting to create a Data Validation formula to test an input cell to
> > make sure that it can be used to automatically assign a file name.
> >
> > I tried putting the Data Validation "custom" formula attached to cell B2,
> > but all text comes back as invalid.
> > InStr(B2,"?"&Chr(34)&"/\<>*|:")=0
> >
> > Any ideas on why this fails?
> >
> > I.E.
> > " used here to show the string limits... not part of the actual string,
> > although Chr(34) would be an invalid filename character in the InStr above.
> > "Test" in the cell SHOULD be valid
> > "Test<1>" SHOULD NOT be valid
> > --
> > Regards,
> > John

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for invalid characters within a string Heath P. Dillon Microsoft VB .NET 4 23rd Feb 2009 04:25 AM
PPT2003 "Can't access <filename> because the filename is invalid" Ace Fekay, MVP Directory Services Microsoft Powerpoint 14 8th Oct 2008 01:07 PM
Formula to replace invalid filename characters tschultz Microsoft Excel Worksheet Functions 2 27th Jan 2006 07:07 PM
Regex expression to replace invalid filename characters. GregMa Microsoft C# .NET 5 10th Mar 2004 06:47 PM
Checking For Invalid Characters Darin Browne Microsoft C# .NET 4 14th Dec 2003 02:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 AM.