Hi Danny, May be this code will work for you:
*Private Sub Worksheet_SelectionChange(ByVal Target As Range)* * * * If Target.Resize(1, 1) = ThisWorkbook.Worksheets("JIBase").Range("G4") Then* * If Len(Trim(Target.Resize(1, 1).Value)) <> 0 Then* * If Not CreateFile(Target.Resize(1, 1)) Then* * MsgBox "Name is not valid as it contains some special character.", vbCritical, "File name is not valid."* * Target.Value = vbNullString* * End If* * End If* * End If* * * *End Sub* * * *Function CreateFile(ByVal strFileName As String) As Boolean* * * * Dim objFSO As Object* * Dim objTFC As Object* * Dim strFilePath As String* * * * strFilePath = Environ("temp") & Application.PathSeparator & strFileName & ".txt"* * Set objFSO = CreateObject("Scripting.FileSystemObject")* * On Error Resume Next* * Set objTFC = Nothing* * Set objTFC = objFSO.CreateTextFile(strFilePath, True)* * On Error GoTo 0: Err.Clear* * * * If Not objTFC Is Nothing Then* * CreateFile = True* * On Error Resume Next* * Kill strFilePath* * On Error GoTo 0: Err.Clear* * Else* * CreateFile = False* * End If* * * * Set objFSO = Nothing* * Set objTFC = Nothing* * strFilePath = vbNullString* * * *End Function* Regards, Lalit Mohan On Wednesday, 2 January 2013 21:12:55 UTC+5:30, Danny Mariens wrote: > > I send workbook in annex. > Protection is on because my collegues use the file with protection on. > I removed password so you can easily switch it on or off. > The cell containing the info that I use to save is G4 on JIBase. > > 2013/1/2 Anoop K Sharma <aks.sh...@gmail.com <javascript:>> > >> can you share workbook? >> >> >> On Wed, Jan 2, 2013 at 8:34 PM, <dannym...@gmail.com <javascript:>>wrote: >> >>> In excel 2012 I'm using the name typed in a cell as a part of the >>> filename when saved via a macro. >>> Because the following characters /\*?"<>| are not allowed in a filename >>> I want to do a check in the cell. >>> The idea is to put a warning in a free cell that the name isn't allowed >>> when it contains one or more of the forbidden characters. >>> I used the =IF function in combination with =SEARCH but I don't know how >>> to use the formulas when I want to check on * ? or " >>> Can somebody help me with that? >>> Thanks. >>> Danny >>> >>> -- >>> Join official Facebook page of this forum @ >>> https://www.facebook.com/discussexcel >>> >>> FORUM RULES >>> >>> 1) Use concise, accurate thread titles. Poor thread titles, like Please >>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >>> will not get quick attention or may not be answered. >>> 2) Don't post a question in the thread of another member. >>> 3) Don't post questions regarding breaking or bypassing any security >>> measure. >>> 4) Acknowledge the responses you receive, good or bad. >>> 5) Jobs posting is not allowed. >>> 6) Sharing copyrighted material and their links is not allowed. >>> >>> NOTE : Don't ever post confidential data in a workbook. Forum owners and >>> members are not responsible for any loss. >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "MS EXCEL AND VBA MACROS" group. >>> To post to this group, send email to excel-...@googlegroups.com<javascript:> >>> . >>> To unsubscribe from this group, send email to >>> excel-macros...@googlegroups.com <javascript:>. >>> Visit this group at http://groups.google.com/group/excel-macros?hl=en. >>> >>> >>> >> >> >> >> -- >> Regards, >> Anoop >> Sr. Developer >> >> -- >> Join official Facebook page of this forum @ >> https://www.facebook.com/discussexcel >> >> FORUM RULES >> >> 1) Use concise, accurate thread titles. Poor thread titles, like Please >> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >> will not get quick attention or may not be answered. >> 2) Don't post a question in the thread of another member. >> 3) Don't post questions regarding breaking or bypassing any security >> measure. >> 4) Acknowledge the responses you receive, good or bad. >> 5) Jobs posting is not allowed. >> 6) Sharing copyrighted material and their links is not allowed. >> >> NOTE : Don't ever post confidential data in a workbook. Forum owners and >> members are not responsible for any loss. >> --- >> You received this message because you are subscribed to the Google Groups >> "MS EXCEL AND VBA MACROS" group. >> To post to this group, send email to excel-...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> excel-macros...@googlegroups.com <javascript:>. >> Visit this group at http://groups.google.com/group/excel-macros?hl=en. >> >> >> > > -- Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To post to this group, send email to excel-macros@googlegroups.com. To unsubscribe from this group, send email to excel-macros+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en.