Calculating Dollars not GBP in a row

piggylumps

Board Regular
Joined
May 11, 2011
Messages
55
Is there anyway I can calculate the sum of a certain currency in a row while ignoring others?

Say for example I have a range of a1:d1, a1 will be $25, b1 will be £36, c1 will be $75 and d1 will be £5.

So what I'm looking for will be a formula in e1 which tells it to sum the range only if the numbers are entered in $'s.

Hope that makes sense.
 
Last edited:
Having just started again on the whole sheet I am now showing #VALUE! in the Total $ column, GBP and EURO are still working fine, but if I put more rows in at the bottom then I get #NAME? returned in the totals column for the new rows.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The #VALUE! error is confusing me, that suggests that the $ values are not in a valid format.

Try the regular excel sum formula in the format of =SUM(G4,G5,G6) on the range holding the $ values, does that give the correct result?

#NAME? would suggest a typing error in the formula, either a mis-spelling of SUMCURR, EURO instead of "EURO", or you have tried to use a named range that doesn't exist.
 
Upvote 0
The =SUM(...) returns a value of 0. All the spelling is correct with the right punctuation marks in the right place
 
Upvote 0
If that returns 0 then there is something wrong with the $ values not the formula, they are being interpreted as text not as numbers.

Try double clicking in one of the $ value cells, does the value change from $ to decimal?

Then press enter, does the sum now show a value?
 
Upvote 0
value didn't change from a $ to a decimal and when I pressed enter it changed the =SUMCURR values to #NAME? in all the total cells along that row. Really don't know what's going on with this now
 
Upvote 0
Is the SUMCURR code still in the code module? That sounds like it could have been deleted / not saved.

With regard to the values issue, that is an input error, whoever has entered the amounts has entered $ into the cell instead of entering the amount and formatting the cell to $.

Once corrected the formula will work.
 
Upvote 0
This is what is in the module:

Public Function SUMCURR(rng As Range, curr As String) As Currency
Select Case curr
Case "USD"
curr = "$"
Case "EURO"
curr = "€"
Case "GBP"
curr = "£"
End Select
For Each cell In rng
If InStr(cell.Text, curr) Then
SUMCURR = SUMCURR + cell.Value
End If
Next
End Function

I think it's still exactly as you first wrote it. Just changing the formats from general to currency now. Sorry to be a pain with this
 
Upvote 0
The code is still correct, but if you're getting #NAME? then excel is not finding it. Which module is the code located in?
 
Upvote 0
Not entirely sure what you mean but I've pressed Alt-F11 and its showing Module1, hope that makes sense to you and I haven't just stated the obvious
 
Upvote 0
Makes perfect sense, and it's the answer I wanted to hear, that means the code is in the right place :)

Is it possible something in your macro security has changed? That could be blocking the code.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,728
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top