• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

If Braces Contain Text Only, Then Remove Braces

I'm having trouble writing a vba code for:


Basically, if the content within the braces do not contain a single number 0-9, then remove braces only.


{both text and numbers} -then leave braces

{all numbers} -then leave braces

{all text} - - - then remove braces


all text is okay to have special characters #,$,%,@ etc..

range starts in A2, but end of column length unknown

length of brace content varies

I only wish to remove braces (inside content shall remain)
 
[pre]
Code:
Sub Remove_Braces()
Dim cn As Boolean
Dim c As Range

For Each c In Range("A2", Range("A2").End(xlDown))
For i = 2 To Len(c.Value) - 1
cn = False
If Asc(Mid(c.Value, i)) > 47 And Asc(Mid(c.Value, i)) < 58 Then
cn = True
Exit For
End If
Next
If cn Then c.Value = Mid(c.Value, 2, Len(c.Value) - 2)
Next

End Sub
[/pre]
 
Back
Top