Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RMO RMO is offline
external usenet poster
 
Posts: 3
Default Function to Sum A Cell Containing Numbers and Text Abbriviations

I have a spreadsheet containing a cell with comments in the following format
to explain changes in value:

1mm mkt, (3.23mm) jnl, 115k px

The comments might change but "mm" will always represent 1,000,000, "k" will
always represent 1,000 and negative values will be in parenthesis.

Is it possible to write a function that removes the comments, converts the
values to their real values and sums them? In the example above the
function should produce a value of negative 2,115,000.

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Function to Sum A Cell Containing Numbers and Text Abbriviations

Why not start with the last function you were given and modify that?

--
Regards,
Tom Ogilvy


"RMO" wrote:

I have a spreadsheet containing a cell with comments in the following format
to explain changes in value:

1mm mkt, (3.23mm) jnl, 115k px

The comments might change but "mm" will always represent 1,000,000, "k" will
always represent 1,000 and negative values will be in parenthesis.

Is it possible to write a function that removes the comments, converts the
values to their real values and sums them? In the example above the
function should produce a value of negative 2,115,000.

Thank you.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Function to Sum A Cell Containing Numbers and Text Abbriviatio

Sub Sumstrings()
Dim tot As Double, s As String
Dim i As Long, Mult As Double
s1 = ActiveCell.Text
For i = 1 To Len(s1)
sChr = Mid(s1, i, 1)
If IsNumeric(sChr) Or sChr = "." Or sChr = "(" Then
If sChr = "(" Then
sChr = "-"
End If
s = s & sChr
Else
If Len(s) 0 Then
Select Case sChr
Case "m"
Mult = 1000000
Case "k"
Mult = 1000
Case Else
Mult = 1
End Select
tot = tot + CDbl(s) * Mult
s = ""
End If
End If
Next
'MsgBox Format(tot, "#,##0")
activecell.Offset(0,1).Value = Format(tot, "#,##0")
Activecell.Offset(0,1).Numberformat = "#,##0;(#,##0)"
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote:

Why not start with the last function you were given and modify that?

--
Regards,
Tom Ogilvy


"RMO" wrote:

I have a spreadsheet containing a cell with comments in the following format
to explain changes in value:

1mm mkt, (3.23mm) jnl, 115k px

The comments might change but "mm" will always represent 1,000,000, "k" will
always represent 1,000 and negative values will be in parenthesis.

Is it possible to write a function that removes the comments, converts the
values to their real values and sums them? In the example above the
function should produce a value of negative 2,115,000.

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
Using a function with numbers & text Cardslinger New Users to Excel 6 June 14th 08 07:10 PM
how to extract numbers from imported cell with text and numbers? jyin Excel Discussion (Misc queries) 3 March 28th 07 01:14 PM
does an IF function only look up numbers & not text? CAPGirl Excel Discussion (Misc queries) 2 October 26th 06 08:20 PM
How do I set up an IF function with text and numbers? Natalie Excel Worksheet Functions 7 November 9th 05 08:50 PM
numbers to text function John T. Sheedy Excel Worksheet Functions 2 March 8th 05 02:13 PM


All times are GMT +1. The time now is 03:00 AM.

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

About Us

"It's about Microsoft Excel"