Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Checking for Invalid filename characters

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Checking for Invalid filename characters

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,4 2,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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Checking for Invalid filename characters

Thanks for the reply.

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

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)),I SERROR(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,4 2,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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to replace invalid filename characters tschultz Excel Worksheet Functions 2 January 27th 06 07:07 PM
List of invalid sheet tab characters? quartz[_2_] Excel Programming 1 December 5th 05 05:10 PM
Checking FileName andy Excel Discussion (Misc queries) 4 August 9th 05 08:56 PM
Invalid characters in Excel Andy Excel Programming 3 December 4th 03 04:34 PM
Checking for invalid dates Matt Pinto Excel Programming 3 November 28th 03 12:11 PM


All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"