Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How to extract text when it's included in the format?

I have a worksheet that contains both numbers and texts. The cells have
units of measurement attached to them, however, they're included in the cell
format.

For example, the cell has 2.0 kg. The format for the cell is custom and
reads #,##0.00 "kg". My worksheet has all sorts of units and I'd like to
pull them aside so that I can convert them. How can I do this if it's
included in the format?

Each unit has it's own cell format - so there's
#,##0.00 "g"
#,##0.00 "%"
and others. This spreadsheet was imported from another system.

I cannot do text to columns as it's a format, not officially text. Any ideas?

I can't
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How to extract text when it's included in the format?

Can you describe what you mean by "I'd like to pull them aside"? That is,
the cell has 12.34 in it and its format is #,###.00 "kg"... what do want to
"pull aside" from that?

--
Rick (MVP - Excel)


"gilliam" wrote in message
...
I have a worksheet that contains both numbers and texts. The cells have
units of measurement attached to them, however, they're included in the
cell
format.

For example, the cell has 2.0 kg. The format for the cell is custom and
reads #,##0.00 "kg". My worksheet has all sorts of units and I'd like to
pull them aside so that I can convert them. How can I do this if it's
included in the format?

Each unit has it's own cell format - so there's
#,##0.00 "g"
#,##0.00 "%"
and others. This spreadsheet was imported from another system.

I cannot do text to columns as it's a format, not officially text. Any
ideas?

I can't


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,805
Default How to extract text when it's included in the format?

You can get the formats in each cell with a macro like this;
'This is just to give an idea...
'This will show the format in each cell in Sheet1 on the corresponding cell
in Sheet2

Sub GetFormat()
Dim i As Integer
Dim j As Integer
For i = 1 To 100
For j = 1 To 20
Sheets("Sheet2").Cells(i, j).Value = Sheets("Sheet1").Cells(i,
j).NumberFormat
Next j
Next i
End Sub


--
To get my email id paste my address in an Excel cell and press Enter...


"gilliam" wrote:

I have a worksheet that contains both numbers and texts. The cells have
units of measurement attached to them, however, they're included in the cell
format.

For example, the cell has 2.0 kg. The format for the cell is custom and
reads #,##0.00 "kg". My worksheet has all sorts of units and I'd like to
pull them aside so that I can convert them. How can I do this if it's
included in the format?

Each unit has it's own cell format - so there's
#,##0.00 "g"
#,##0.00 "%"
and others. This spreadsheet was imported from another system.

I cannot do text to columns as it's a format, not officially text. Any ideas?

I can't

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How to extract text when it's included in the format?

Okay, based on Sheeloo's post and a re-reading of your subject line, I'm
guessing you want to put the kg from the #,###.00 "kg" format into a cell.
You can use a User Defined Function (UDF) to do that. From the worksheet,
press Alt+F11 to go into the VBA editor and click Insert/Module on its menu
bar, then copy/paste this code into the code window that appeared...

Function GetUnits(C As Range) As String
GetUnits = Replace(Mid(Range("B1").NumberFormat, InStrRev( _
Range("B1").NumberFormat, " ") + 1), """", "")
End Function

Now, go back to the worksheet and (assuming A1 has one of your indicated
cell formats) enter this into a cell (other than A1, of course)...

=GetUnits(A1)

and the units part of the cell format will be displayed.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Can you describe what you mean by "I'd like to pull them aside"? That is,
the cell has 12.34 in it and its format is #,###.00 "kg"... what do want
to "pull aside" from that?

--
Rick (MVP - Excel)


"gilliam" wrote in message
...
I have a worksheet that contains both numbers and texts. The cells have
units of measurement attached to them, however, they're included in the
cell
format.

For example, the cell has 2.0 kg. The format for the cell is custom and
reads #,##0.00 "kg". My worksheet has all sorts of units and I'd like to
pull them aside so that I can convert them. How can I do this if it's
included in the format?

Each unit has it's own cell format - so there's
#,##0.00 "g"
#,##0.00 "%"
and others. This spreadsheet was imported from another system.

I cannot do text to columns as it's a format, not officially text. Any
ideas?

I can't



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
Need to extract certain text from text string Trista @ Pacific Excel Worksheet Functions 4 November 21st 07 07:07 PM
Extract text from large Text ldiaz Excel Discussion (Misc queries) 4 November 14th 07 01:21 AM
Can a cell in excel contain text and have a formula included? pennpro Excel Discussion (Misc queries) 3 October 4th 06 10:54 PM
EXTRACT TEXT FROM TEXT STRING carricka Excel Worksheet Functions 4 July 8th 05 11:00 AM
Extract text someone Excel Worksheet Functions 12 January 23rd 05 12:24 AM


All times are GMT +1. The time now is 04:28 PM.

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"