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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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.
 
Upvote 0
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.
 
Upvote 0
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;)
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0
Your default currency must be Euros, try

[$$-409]#,##0.00

In place of

$#,##0.00
 
Upvote 0
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:
Upvote 0
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:
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,527
Members
449,037
Latest member
tmmotairi

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