One way:
Public Sub ConstantsToFormulae()
Const sTEMPLATE As String = "=$$+0"
Dim rTargets As Range
Dim rCell As Range
On Error Resume Next 'in case no selected constants
Set rTargets = Selection.SpecialCells( _
xlCellTypeConstants, xlNumbers)
On Error GoTo 0
If Not rTargets Is Nothing Then
For Each rCell In rTargets
With rCell
.Formula = Replace(sTEMPLATE, "$$", _
Format(Int(.Value * 1000) / 1000, "0.000"))
End With
Next rCell
End If
End Sub
Select the cells to be changed and run the macro.
If you want this to be compatible with XL97 and MacXL versions, change
"Replace(" to "Application.Substitute("
In article ,
"John Britto" wrote:
I shall be thankful if any one helps me to create a macro or so..to solve the
following:
I have hunderes of cells with 8 digits decimals. When I click a maco the
cell to be updated as:
Presnt date: 1520.12565415
Desired Result: =1520.125+0
Thanks for the attentino.
John Britto
|