Thread: Formatting text
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
srosetti srosetti is offline
external usenet poster
 
Posts: 33
Default Formatting text

On Nov 3, 2:54*am, Patrick Molloy
wrote:
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
.




I've played a bit with the UDF. Cant seem to get it to do what I want
in the Column labeled desclong I'm not really versed in coding the
UDF.. any ideas on how to focus it to run on the one column?