Linking the currency format of a range to another cell?

yorkshirelad

Board Regular
Joined
Aug 18, 2003
Messages
100
I have a range of cells D1:D23 that need to display prices in Euros or Sterling.

The user can select a currency from a drop-down in cell C4, this then populates the cells D1:D23 with the correct data

Is there a way I can automatically change the currency format of this range from £'s to Euros depending on the cell contents of C4.

I've had a few goes at setting up conditional formatting with a formula, but the results aren't consistent.

Many thanks for any assistance
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
IFAIK, you can't change numberformats with CF.

Right click the sheet tab, select view code and insert the following code. You'll need to change the range reference E1:E100 to suit.

Having said that, I'm using xl2002, so maybe later versions are more flexible.

Code:
 Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$4" Then
        Application.EnableEvents = False
        With Range("E1:E100")
            Select Case Target.Value
                Case "Euro"
                    .NumberFormat = "#,##0.00 [$€-1]"
                Case "Sterling"
                    .NumberFormat = "£#,##0.00"
            End Select
        End With
        Application.EnableEvents = True
    End If
End Sub
I used select..case so you can include more than 2 options easily
 
Upvote 0
How is "this then populates the cells D1:D23 with the correct data" done?
Is a VBA solution wanted? (It may have to be)
What sort of things are in the dropdown, and is it a Data Validation dropdown or something else?

It could be something in the sheet's change event:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$4" Then
    With Range("D1:D23")
        If Range("C4").Value = "Euro" Then
            .NumberFormat = "[$€-2] #,##0.00"
        Else
            .NumberFormat = "$#,##0.00"
        End If
    End With
End If
End Sub
 
Upvote 0
IFAIK, you can't change numberformats with CF.

Right click the sheet tab, select view code and insert the following code. You'll need to change the range reference E1:E100 to suit.

Having said that, I'm using xl2002, so maybe later versions are more flexible.

Code:
 Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$4" Then
        Application.EnableEvents = False
        With Range("E1:E100")
            Select Case Target.Value
                Case "Euro"
                    .NumberFormat = "#,##0.00 [$€-1]"
                Case "Sterling"
                    .NumberFormat = "£#,##0.00"
            End Select
        End With
        Application.EnableEvents = True
    End If
End Sub
I used select..case so you can include more than 2 options easily

Many thanks Weaver - sorry for the delay in posting a reply I've been away for the weekend. That's great.
 
Upvote 0
How is "this then populates the cells D1:D23 with the correct data" done?
Is a VBA solution wanted? (It may have to be)
What sort of things are in the dropdown, and is it a Data Validation dropdown or something else?

It could be something in the sheet's change event:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$4" Then
    With Range("D1:D23")
        If Range("C4").Value = "Euro" Then
            .NumberFormat = "[$€-2] #,##0.00"
        Else
            .NumberFormat = "$#,##0.00"
        End If
    End With
End If
End Sub

Many thanks p45cal - sorry for the delay in replying I've been away for the weekend. That's really appreciated
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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