Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using a function with numbers & text | New Users to Excel | |||
how to extract numbers from imported cell with text and numbers? | Excel Discussion (Misc queries) | |||
does an IF function only look up numbers & not text? | Excel Discussion (Misc queries) | |||
How do I set up an IF function with text and numbers? | Excel Worksheet Functions | |||
numbers to text function | Excel Worksheet Functions |