Hi,
I have a function that takes the monthly number in a cell, and converts it in annual value. Then it copies again that value in the cell. But there's a side effect. The cell itself looses its original number format. For exemple, it's no longer a currency format. My question is how can I save just before doing the operation the number format in a variable and then use this variable to aply this format to the cell again? Is it possible?
I'll copy too my function code here.
By the way, I tried this : Selection.NumberFormat = xlNumber and strangely, when it put the value in the cell again, it displays "-4145". However, if you look inside the cell, the true value is the correct one. Weird...
Thx!
Werner
Code
Sub Math_Mensuel()
Dim DblNombre As Double
Dim StrNombre As String
StrNombre = ""
Dim ActiveRange As Range
Set ActiveRange = ActiveCell
'We put data in the inputbox.
StrNombre = CDbl(Application.InputBox(Prompt:="Entrez le nombre mensuel à convertir en annuel:", Type:=1))
StrNombre = StrNombre * 12
ActiveCell.Select
ActiveCell = StrNombre
Display More