Some months back I did receive the following code, can someone help me, how to use this code, I am not very good with VB or macros. What I want is to convert decimals to fractions (with denominators of 2, 4, 8, 16 or 32)
Help is highly appreciated
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' note that this implies that in Excel you did Insert | Name | Define...
' and defined a named range «ChangeToFractions» for those cells
' that you want converted from decimals to fractions
const c_strTestRangeName as string = "ChangeToFractions"
Dim rngCell As Range
If Intersect(Target, range(c_strTestRangeName)) Is Nothing Then Exit Sub
application.enableevents = false
for each rngCell in Intersect(Target, range(c_strTestRangeName)).cells
with rngcell
.value = Round(.Value * 32, 0) / 32
end with
next rngcell
application.enableevents = true
End Sub
Help is highly appreciated
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' note that this implies that in Excel you did Insert | Name | Define...
' and defined a named range «ChangeToFractions» for those cells
' that you want converted from decimals to fractions
const c_strTestRangeName as string = "ChangeToFractions"
Dim rngCell As Range
If Intersect(Target, range(c_strTestRangeName)) Is Nothing Then Exit Sub
application.enableevents = false
for each rngCell in Intersect(Target, range(c_strTestRangeName)).cells
with rngcell
.value = Round(.Value * 32, 0) / 32
end with
next rngcell
application.enableevents = true
End Sub