Hi Sonal, Sure --
String * length indicates a "fixed-length string" of length number of characters in length. I used it because the variable will always hold exactly one character, but the usual "variable length string" (declared as just String) would have worked too. Asa From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of SG Sent: Tuesday, June 05, 2012 2:34 AM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ Text Cleaning Hi Asa, your code really works exact for me.Thanks for the help but can u please explain why you have done this "Character As String * 1". On Monday, June 4, 2012 9:14:07 PM UTC+5:30, Asa R. wrote: I re-read your query and I see you only wanted alphabet characters. I had this include numbers as well. for just alphabetical characters A-Z and a-z, here is the correction: Function CleanText(Text As String) As String Dim NewText As String, Character As String * 1, Position As Long For Position = 1 To Len(Text) Character = Mid(Text, Position, 1) If Character Like "[A-z]" Then NewText = NewText & Character End If Next Position CleanText = NewText End Function By the way, welcome to the group! Asa From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of Asa Rossoff Sent: Monday, June 04, 2012 8:38 AM To: excel-macros@googlegroups.com Subject: RE: $$Excel-Macros$$ Text Cleaning Hi Sonal, Another function for you: Function CleanText(Text As String) As String Dim NewText As String, Character As String * 1, Position As Long For Position = 1 To Len(Text) Character = Mid(Text, Position, 1) If Character Like "[A-z]" Or Character Like "#" Then NewText = NewText & Character End If Next Position CleanText = NewText End Function You can use this as a UDF in a worksheet formula or call it from other macros. Asa From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of sonal gupta Sent: Monday, June 04, 2012 8:15 AM To: excel-macros@googlegroups.com Subject: $$Excel-Macros$$ Text Cleaning Hi, This is my first post in this group.I have learnt many things from this group.I'm finding difficulty in cleaning the range in which each cell has string like " rahul;6e3-".I need a macro which will clean the special characters,spaces & numbers & leave the alphabets only. Thanks in advance. -- FORUM RULES (986+ members already BANNED for violation) 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) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to excel-macros@googlegroups.com To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 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) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to excel-macros@googlegroups.com To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 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) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to excel-macros@googlegroups.com To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 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) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com