Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Formatting text

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
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?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Formatting text

On Nov 3, 10:04*am, srosetti wrote:
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?



Problem is I have some data I need in fractions. but when I copy the
fraction data into a text field it loses its number formatting and
turns back into decimal form.

I'll copy some real data from my spreadsheet so u can see whats going
on. *This is what I see after I put the fractions from column H4 L4 to
the end of text in column N4 'Widget'

H4 L4 N4
9 1/4 19 7/8 Widget 19.875" x 9.25"

I have thousands of entries so I don't want to do this by hand.. I've
tried everything I know to copy the fractions over, but no luck.
Someone wrote a UDF function earlier, but it didn't exactly work for
me. I'm trying to just simplify the steps by putting in the column H
and L which have the decimal form and I converted them to fractions..
My raw data is all in decimal so I have to work from that to get it to
fractions.

What I need my final data to look like is..

N4 Widget 19 7/8" x 9 1/4"

It would also be acceptable if the data ended up like

N4 Widget 19 7/8 x 9 1/4 inches

The quotes for inches is best, but if not possible I can use the word
inches too.

Thank You
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force column formatting (text, date, etc) when loading a fixed width text file into an array? ker_01 Excel Programming 3 October 21st 08 08:45 PM
Find formatting in text in cell, insert tags around formatting. CarlC Excel Programming 2 February 27th 08 09:26 PM
Formula Text String: Formatting Text and Numbers? dj479794 Excel Discussion (Misc queries) 5 June 30th 07 12:19 AM
Conditional Formatting based on text within a cell w/ text AND num Shirley Excel Worksheet Functions 2 December 22nd 06 01:40 AM
Formatting text in a user form text box DB Excel Programming 0 July 23rd 05 08:09 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"