View Single Post
 
Old September 22nd, 2009, 09:01 AM
DoriftuEvo DoriftuEvo is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gluefish View Post
You want to get rid of the brackets.

You could use the instructions stanleydgromjr (above) used to install a macro.
Personally, I don't bother with the macros, just put a sub in the code page using alt-F11, to access it. To run it, place the cursor in the code and hit F5.

Everyone else but me seems to think it was necessary to just take the brackets from the left and right side of your numbers. Looking at it, it appeared you just wanted plain numbers, and the place of the brackets didn't matter.

Also, I think setting the range unnecessarily complicates matters when you can just make a loop that uses cell references.

Try this: assuming your data is from A1 to A100:

Code:
Sub removeBrackets()
    Dim r
    For r = 1 To 100
        Cells(r, 1) = Replace(Cells(r, 1), "[", "")
        Cells(r, 1) = Replace(Cells(r, 1), "]", "")
    Next
End Sub
(That left me with:)
2.00657892
3.10558234
10.2345342
14.2560234
4.13423105
5.14613461
4.23123451

2.23453253
12.3452352
15.1624525
14.2145324
Thanks, that worked just fine.

The brackets got there because I put them around all values over 10 in order to omit them from a graph I was looking at (I'm sure you guys would have a better solution for that as well). I then decided I wanted to look at the graph with all the numbers and didn't want to manually remove the brackets from all 837 rows.