Text Cleaning

Text Cleaning

Post by SG » Wed, 06 Jun 2012 18:44:27



Rajan...Thanks for the help but still your code is returning numbers .


>  Ah , *Cod* is just a integer type *variable* , that will hold the *ACSII
> Code* or each character in string,

> * *

> *Regards*

> *Rajan verma*

> *+91 7838100659 [IM-Gtalk]*



> *Sent:* 04 June 2012 9:04

> *Subject:* Re: $$Excel-Macros$$ Text Cleaning

> again thanks but i know how to run a macro what i was asking is
> the explanation for "COD" that ypu have used  in your code.

> Ok..

> Press ALT+F11

> ALT + I M

> Paste this code there

> Use Function Worksheet Like :

> = RemoveSpecialCharacters(YourString)

> * *

> *Regards*

> *Rajan verma*

> *+91 7838100659 [IM-Gtalk]*



> *Sent:* 04 June 2012 8:58

> *Subject:* Re: $$Excel-Macros$$ Text Cleaning

> Thanks rajan, but i'm new to macros..can you please explain the use of
> "COD" in this.


>  Try this :

> Public Function RemoveSpecialCharacters(Shname As String) As String

> Dim Cod As Integer

> Dim ShN As String

>             For i = 1 To Len(Shname)

>                 Cod = Asc(Mid(Shname, i, 1))

>                         If (Cod > 47 And Cod < 58) Or (Cod > 64 And Cod <
> 91) Or (Cod > 96 And Cod < 123) Then

>                         ShN = ShN & Mid(Shname, i, 1)

>                         End If

>             Next

>             RemoveSpecialCharacters = ShN

> End Function

> * *

> *Regards*

> *Rajan verma*

> *+91 7838100659 [IM-Gtalk]*



> *Sent:* 04 June 2012 8:45

> *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 unsubscribe, send a blank email to

> --
> 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 unsubscribe, send a blank email to

> --
> 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 unsubscribe, send a blank email to


 
 
 

Text Cleaning

Post by Asa Rossof » Wed, 06 Jun 2012 18:47:47


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


On Behalf Of SG
Sent: Tuesday, June 05, 2012 2:34 AM

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".

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


On Behalf Of Asa Rossoff
Sent: Monday, June 04, 2012 8:38 AM

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


On Behalf Of sonal gupta
Sent: Monday, June 04, 2012 8:15 AM

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 unsubscribe, send a blank email to

--
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 unsubscribe, send a blank email to

--
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 unsubscribe, send a blank email to