Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Devlin
 
Posts: n/a
Default conditional sum question

Hello,

I want to add a range of values, but they are formatted differently:
some of them are formatted with the dollar currency, others with the
euro currency. Excel treats them equally, as numbers, but I need to
make different sums automatically - I want to add only dollars or only
euros. Is there a way to use SUMIF? Is there a way to do this?

My data look like this:

$ 4,000
$ 2,230
=80 23,330
$ 12,212
=80 2,210
=80 900
$ 1,125
etc...

THANKS A LOT,
Devlin

  #2   Report Post  
John Michl
 
Posts: n/a
Default

Unless you use some VB code to determine the type of currency based on
the format, I think you'll need to add a second column that indicates
the type. Then you'll be able to use SumIF.

You are correct in pointing out that Excel thinks of these values as
numbers not currency values. Same with other numerical formats such as
dates and times. The format only dresses up the look. Underneath is a
number like most any other number.

- John

  #3   Report Post  
Devlin
 
Posts: n/a
Default

I will gladly add another column, but what formula should I use? I
can't input the Euro or Dollar signs in each cell of the column
manually, so I have to find a formula to do this for me... and after
that use a sumif :)

  #4   Report Post  
Duke Carey
 
Posts: n/a
Default

Paste the code below into a VBA module in your workbook, then use it to
identify the format type in cell A1 by entering this formula into cell B1

=CurrencyType(A1)

for guidance on how to use code, look at this site

http://www.mvps.org/dmcritchie/excel/getstarted.htm


Public Function CurrencyType(rng As Range) As String
If InStr(1, rng(1, 1).NumberFormat, "‚¬") 0 Then
CurrencyType = "Euro"
Exit Function
ElseIf InStr(1, rng(1, 1).NumberFormat, "$") 0 Then
CurrencyType = "Dollar"
Exit Function
End If
CurrencyType = "None"
End Function


"Devlin" wrote:

I will gladly add another column, but what formula should I use? I
can't input the Euro or Dollar signs in each cell of the column
manually, so I have to find a formula to do this for me... and after
that use a sumif :)


  #5   Report Post  
Duke Carey
 
Posts: n/a
Default

The function is lacking a line of code and, as a result, doesn't update
automatically.
It looks like that code ought to be as shown below. However, changing the
format of a cell doesn't appear to trigger a recalc of the sheet and,
derivatively, this function. So, after you change a cell's format, press the
F9 key to make these things all recalculate

Public Function CurrencyType(rng As Range) As String
Application.Volatile
If InStr(1, rng(1, 1).NumberFormat, "‚¬") 0 Then
CurrencyType = "Euro"
Exit Function
ElseIf InStr(1, rng(1, 1).NumberFormat, "$") 0 Then
CurrencyType = "Dollar"
Exit Function
End If
CurrencyType = "None"
End Function


"Duke Carey" wrote:

Paste the code below into a VBA module in your workbook, then use it to
identify the format type in cell A1 by entering this formula into cell B1

=CurrencyType(A1)

for guidance on how to use code, look at this site

http://www.mvps.org/dmcritchie/excel/getstarted.htm


Public Function CurrencyType(rng As Range) As String
If InStr(1, rng(1, 1).NumberFormat, "‚¬") 0 Then
CurrencyType = "Euro"
Exit Function
ElseIf InStr(1, rng(1, 1).NumberFormat, "$") 0 Then
CurrencyType = "Dollar"
Exit Function
End If
CurrencyType = "None"
End Function


"Devlin" wrote:

I will gladly add another column, but what formula should I use? I
can't input the Euro or Dollar signs in each cell of the column
manually, so I have to find a formula to do this for me... and after
that use a sumif :)




  #6   Report Post  
RagDyer
 
Posts: n/a
Default

Since you're willing to use a "helper" column, you could try this:

Values in A1:A20,

Enter this in B1 and copy down to B20:

=LEFT(CELL("format",A1))

Then use this to total:

=SUMIF(B1:B20,"C",A1:A20)

--
HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================



"Devlin" wrote in message
oups.com...
I will gladly add another column, but what formula should I use? I
can't input the Euro or Dollar signs in each cell of the column
manually, so I have to find a formula to do this for me... and after
that use a sumif :)


  #7   Report Post  
Devlin
 
Posts: n/a
Default

Thank you all very much. The information was very helpful.

Devlin

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
Conditional Formating Extreme Question Heather Excel Worksheet Functions 5 May 8th 05 08:06 PM
Conditional Format Question DougS Excel Worksheet Functions 3 May 3rd 05 01:36 AM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM
Excel Macro Question about Conditional Formatting David Britton via OfficeKB.com New Users to Excel 3 February 10th 05 02:23 PM
conditional formatting question chris Excel Worksheet Functions 2 January 5th 05 03:51 PM


All times are GMT +1. The time now is 06:10 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"