zeekiehafa
New Member
- Joined
- May 15, 2012
- Messages
- 9
Ok so, I have a list of data. Some of them look like this "4-1/2 (114)" but some look like this
"4 (114)". I want to discard the entire item in brackets. The problem I am having however is that when I write a code to automatically remove the brackets and their contents, all of the items that look like this "4-1/2 (114)" get converted to dates. I want them to be converted to numbers. For example, "4-1/2 (114)" should end up being the number 4.5 and "4 (114)" should end up being the number 4.
Help? Please?
Here's the situation
And here's the code I've been trying to use, that converts them to dates sometimes.
"4 (114)". I want to discard the entire item in brackets. The problem I am having however is that when I write a code to automatically remove the brackets and their contents, all of the items that look like this "4-1/2 (114)" get converted to dates. I want them to be converted to numbers. For example, "4-1/2 (114)" should end up being the number 4.5 and "4 (114)" should end up being the number 4.
Help? Please?
Here's the situation
And here's the code I've been trying to use, that converts them to dates sometimes.
Code:
Dim cell As Range
Dim v As Variant
Dim c As Integer
Do While ActiveCell.Value <> ""
c = 0
Do While ActiveCell.Value <> ""
On Error Resume Next
For Each cell In Intersect(Selection.Cells, ActiveSheet.UsedRange)
If VarType(cell.Value) = vbString Then
v = Evaluate(Replace(cell.Value, "-", " "))
If VarType(v) = vbDouble Then cell.Value = v
End If
Next cell
ActiveCell.Value = Left(ActiveCell, InStr(1, ActiveCell.Value, "(") - 2)
ActiveCell.Offset(0, 1).Select
c = c + 1
Loop
ActiveCell.Offset(1, -c).Select
Loop