excelnoob1985
New Member
- Joined
- Jul 22, 2015
- Messages
- 6
Hi all,
I have implemented some VBA script so that when I change the type of currency in a drop down box on a sheet called "Data Sheet", all currency cells only in the rest of the workbook will change to reflect the new type of currency selected.
This works fine for most of the sheets where there are only a few currency cells where I have managed to restricted the script cover a selection of cells. However for one of my sheets called "Fees", there are thousands of cells, which are not all together, to change. I have implemented the following code (this is only part of it as it is repeated in the VBA script to cover all 12 currencies in the drop down box) but it takes anywhere between 5 - 10 seconds to run each time I change the currency.
Is there anyway that I can improve it to make it run faster (I have highlighted the section of the code that I think is causing the slow running).
Thank you!
--------------------------
If Target.Address = "$G$1" Then
If Target.Value = "GBP" Then Sheets("MatterTeam&ApplicableRates").Range("D20:D118").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Disbursements").Range("E:E").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Monthly Profiling Data").Range("B8:B27,E8:CB29,B41:B60,E41:CB62").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Monthly Costs").Range("C13:E106").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then
For Each c In Sheets("Fees").Range("A1:GZ111").Cells
If c.NumberFormat = "£#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "€#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$$-409]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$AED] #,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$A$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$TRY] #,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "¥#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$HK$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$S$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$FK£]#,##0.00" Then c.NumberFormat = "£#,##0.00"
Next
End If
If Target.Address = "$G$1" Then
If Target.Value = "EUR" Then Sheets("MatterTeam&ApplicableRates").Range("D20:D118").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Disbursements").Range("E:E").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Monthly Profiling Data").Range("B8:B27,E8:CB29,B41:B60,E41:CB62").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Monthly Costs").Range("C13:E106").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then
For Each c In Sheets("Fees").Range("A1:GZ111").Cells
If c.NumberFormat = "£#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "€#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$$-409]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$AED] #,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$A$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$TRY] #,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "¥#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$HK$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$S$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$FK£]#,##0.00" Then c.NumberFormat = "€#,##0.00"
Next
End If
I have implemented some VBA script so that when I change the type of currency in a drop down box on a sheet called "Data Sheet", all currency cells only in the rest of the workbook will change to reflect the new type of currency selected.
This works fine for most of the sheets where there are only a few currency cells where I have managed to restricted the script cover a selection of cells. However for one of my sheets called "Fees", there are thousands of cells, which are not all together, to change. I have implemented the following code (this is only part of it as it is repeated in the VBA script to cover all 12 currencies in the drop down box) but it takes anywhere between 5 - 10 seconds to run each time I change the currency.
Is there anyway that I can improve it to make it run faster (I have highlighted the section of the code that I think is causing the slow running).
Thank you!
--------------------------
If Target.Address = "$G$1" Then
If Target.Value = "GBP" Then Sheets("MatterTeam&ApplicableRates").Range("D20:D118").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Disbursements").Range("E:E").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Monthly Profiling Data").Range("B8:B27,E8:CB29,B41:B60,E41:CB62").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then Sheets("Monthly Costs").Range("C13:E106").NumberFormat = "£#,##0.00"
If Target.Value = "GBP" Then
For Each c In Sheets("Fees").Range("A1:GZ111").Cells
If c.NumberFormat = "£#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "€#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$$-409]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$AED] #,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$A$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$TRY] #,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "¥#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$HK$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$S$]#,##0.00" Then c.NumberFormat = "£#,##0.00"
If c.NumberFormat = "[$FK£]#,##0.00" Then c.NumberFormat = "£#,##0.00"
Next
End If
If Target.Address = "$G$1" Then
If Target.Value = "EUR" Then Sheets("MatterTeam&ApplicableRates").Range("D20:D118").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Disbursements").Range("E:E").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Monthly Profiling Data").Range("B8:B27,E8:CB29,B41:B60,E41:CB62").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then Sheets("Monthly Costs").Range("C13:E106").NumberFormat = "€#,##0.00"
If Target.Value = "EUR" Then
For Each c In Sheets("Fees").Range("A1:GZ111").Cells
If c.NumberFormat = "£#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "€#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$$-409]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$AED] #,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$A$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$TRY] #,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "¥#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$HK$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$S$]#,##0.00" Then c.NumberFormat = "€#,##0.00"
If c.NumberFormat = "[$FK£]#,##0.00" Then c.NumberFormat = "€#,##0.00"
Next
End If