Hello,
I'm trying to create a function that converts currencies. When the currency is converted it also needs to change the number format of the cell that the function was typed in. This is so that it will reflect the new currency.
I have two snippets of code. It is the same code. One is in a sub routine and one is in a function. For some reason it will not let me change the number format (or cell format for that matter) with the function but works as expected with the sub routine. Is this a known VBA issue, or is there a workaround?
This code does nothing
This code works exactly as expected
Cheers,
Andy
I'm trying to create a function that converts currencies. When the currency is converted it also needs to change the number format of the cell that the function was typed in. This is so that it will reflect the new currency.
I have two snippets of code. It is the same code. One is in a sub routine and one is in a function. For some reason it will not let me change the number format (or cell format for that matter) with the function but works as expected with the sub routine. Is this a known VBA issue, or is there a workaround?
This code does nothing
Code:
Function numformat()
Range("A2").NumberFormat = "£#,##0.00"
End Function
This code works exactly as expected
Code:
Sub numformat_sub()
Range("A2").NumberFormat = "£#,##0.00"
End Sub
Cheers,
Andy