Thread: Formatting text
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Formatting text

a UDF could be used...here's somethign to get you started...though you'll
definitely need to fine tune it...

Option Explicit
Sub test()
MsgBox parser1("Widget 12.25 x 12.1875")
End Sub
Function parser1(text As String) As Variant
Dim pos As Long
Dim result As String
Dim prod As String
Dim hgt As Double
Dim wdth As Double
parser1 = text
If text Like "* x *" Then
pos = InStr(text, " x ")
pos = InStr(Left(text, pos - 1), " ")
result = Left(text, pos)
text = Mid(text, pos + 1)
pos = InStr(Left(text, pos - 1), " ")
hgt = Left(text, pos - 1)
text = Mid(text, pos + 3)
wdth = text
result = result & Format$(hgt, "0 #/8") & " x " & _
Format$(wdth, "0 #/8")
parser1 = result
End If
End Function



"srosetti" wrote:

I have a description field in Column N. It has text in it with some
numbers..

It might look like this.

Data in Column N Row 2
Widget 12.25 x 12.1875

I'm pretty sure excel sees this whole field as Text.

The descriptions are in various lengths, but most of the 1000 entries
have a dimension entry.

I want to display the decimals in fractions and also format the
numbers to reflect inches. ie in. or the "

VBA is probably easiest, but anyone have an idea on how to do this??


Thanks
.