A
akh2103
Hello--I have a macro that inserts tables from word into excel. The
data in the word tables is in percentages (ex. 4%) where we need it to
be in simple integers (ex. 4). I have written a program that makes this
conversion and it works fine except for occasional small rounding
errors (ex. it will turn 4% into the number 5). I don't know how excel
rounds so well, but can anyone spot the place in my code (below) where
the rounding errors are occuring. Is there an easy way to solve this
problem or an easier way to make this conversion?
Thanks, Abe
Sub values()
Dim item As Range
ActiveSheet.UsedRange.Select
For Each item In Selection
If item.Value < 1 And item.Value = 0 = False Then item.Value =
item.Value * 100 Else
Next
ActiveSheet.UsedRange.Select
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(*
""-""??_);_(@_)"
Selection.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""??_);_(@_)"
End Sub
data in the word tables is in percentages (ex. 4%) where we need it to
be in simple integers (ex. 4). I have written a program that makes this
conversion and it works fine except for occasional small rounding
errors (ex. it will turn 4% into the number 5). I don't know how excel
rounds so well, but can anyone spot the place in my code (below) where
the rounding errors are occuring. Is there an easy way to solve this
problem or an easier way to make this conversion?
Thanks, Abe
Sub values()
Dim item As Range
ActiveSheet.UsedRange.Select
For Each item In Selection
If item.Value < 1 And item.Value = 0 = False Then item.Value =
item.Value * 100 Else
Next
ActiveSheet.UsedRange.Select
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(*
""-""??_);_(@_)"
Selection.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""??_);_(@_)"
End Sub