Exchange in excel

Marcelino

New Member
Joined
Jun 25, 2010
Messages
13
Hi,

I create an excel document, where i write how much money i've paid. I write numbers in euros. My problem is, that i want a macro, whose exchange all the numbers into other currency, for example: dollars.

I want use 1 toggle button. When button is pressed all the numbers are in dollars, and when togle button is unpressed, all the numbers are in euros.

Can you help me?

...sorry for my bad english

THank you very much;)
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

combatvolcano

Board Regular
Joined
Jan 13, 2010
Messages
69
ActiveCell.EntireColumn.NumberFormat = "[$€-2] #,##0.00"

This will change the format for the active column but has nothing to do with exchange rates.

You'll need to use the macro recorder to find the formats that suit you.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Hi Marcelino,
There are a number of ways to show the amounts in the different currencies. It could all be done with formulas (using an extra column) or you could use a macro. There is also the consideration that the exchange rate changes, so with formulas or vba, I believe you'll want to use a cell somewhere that can house the exchange rate for the macro (or formulas) to work off of.

Can you describe your data layout (or at least an example)? The less guessing we have to do, the quicker a meaningful solution can be suggested.
 

Marcelino

New Member
Joined
Jun 25, 2010
Messages
13
Thank you for your reaction

This is simple example of my document:

screentlx.jpg


Exchange is toggle button and when is unpressed in all cells are numbers in euros, and when is pressed all the numbers are in dollars.
In the cell C10 is actual exchange rate.

Thank you again for your help;)
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456

ADVERTISEMENT

Here's something you can try.
Insert an ActiveX button (like from the Controls Toolbox toolbar, not the standard "Forms" toolbar button) on your sheet, leave it named CommandButton1 (or change the code to reflect it's new name) and use this code for it.
Code:
Private Sub CommandButton1_Click()
Dim Lr&, CnvrtRng As Range, i As Range
Lr = Cells(Rows.Count, "B").End(xlUp).Row
Set CnvrtRng = Range("B2:B" & Lr)
Application.ScreenUpdating = False
    With CnvrtRng
        If .NumberFormat = "$#,##0.00" Then
           .NumberFormat = "[$€-2] #,##0.00"
            For Each i In CnvrtRng
                i.Value = i.Value / Range("C10").Value
            Next
            CommandButton1.Caption = "Display Dollars"
        Else
           .NumberFormat = "$#,##0.00"
            For Each i In CnvrtRng
                i.Value = i.Value * Range("C10").Value
            Next
            CommandButton1.Caption = "Display Euros"
        End If
    End With
    
Application.ScreenUpdating = True
End Sub

Does that get you anywhere close?
 

Marcelino

New Member
Joined
Jun 25, 2010
Messages
13
It works, but symbol of curency is still €.

And there is one problem. When I change a currency, all the numbers is changed, it's all right, but SUM column isn't right. The formula of SUM isn't there, and this column is only number.
 

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,025
Office Version
  1. 365
  2. 2016

ADVERTISEMENT

Your default currency must be Euros, try

[$$-409]#,##0.00

In place of

$#,##0.00
 

Marcelino

New Member
Joined
Jun 25, 2010
Messages
13
HalfAce,

Can you do it, that macro exchange only columns, where are numbers? It means, that macro don't eschange a columns where are formulas (like sum, count)
But currency of numbers change in all of the columns, where is number in document.
 
Last edited:

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,025
Office Version
  1. 365
  2. 2016
Not sure when HalfAce is around but this is his code amended

Code:
Private Sub CommandButton1_Click()
Dim Lr&, CnvrtRng As Range, i As Range
Lr = Cells(Rows.Count, "B").End(xlUp).Row - 1
Set CnvrtRng = Range("B2:B" & Lr)
Application.ScreenUpdating = False
    With CnvrtRng
        If .NumberFormat = "[$$-409]#,##0.00" Then
           .NumberFormat = "[$€-2] #,##0.00"
            For Each i In CnvrtRng
                i.Value = i.Value / Range("C10").Value
            Next
            Range("B" & Lr + 1).NumberFormat = "[$€-2] #,##0.00"
            CommandButton1.Caption = "Display Dollars"
        Else
           .NumberFormat = "[$$-409]#,##0.00"
            For Each i In CnvrtRng
                i.Value = i.Value * Range("C10").Value
            Next
            Range("B" & Lr + 1).NumberFormat = "[$$-409] #,##0.00"
            CommandButton1.Caption = "Display Euros"
        End If
    End With
    
Application.ScreenUpdating = True
End Sub

It will leave the last cell containing SUM alone.
 
Last edited:

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Yes, Dave's got the same exact idea I have. (Amend the Lr by a row.)
Lr = Cells(Rows.Count, "B").End(xlUp).Row - 1

His amended code is working perfect for me, as I understand your intent.

Mind you, this is set up to work with the example layout provided in your earlier post. If there are significant differences between tour example and your real data layout then there's bound to be unexpected or unwanted results.
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,290
Messages
5,836,444
Members
430,429
Latest member
monkeyhalf

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
Top