YasserKhalil
04-26-2012, 03:33 AM
Hello everyone
I have the following formula which I used to round numbers specially
for example :
20.1 and 20.2 becomes 20
20.3, 20.4, 20.5,20.6,20.7 becomes 20.5
20.8 and 20.9 becomes 21
I want to convert it to use it in VBA
The fomula:::
=IF(OR(ROUND(MOD(A1;1);1)=0.1;ROUND(MOD(A1;1);1)=0.2;ROUND(MOD(A1;1);1)=0.6 ;ROUND(MOD(A1;1);1)=0.7);FLOOR(A1;0.5);CEILING(A1;0.5))
A1 in this formula should be replaced by cel in vba...
The summary is that VBA look at the cell value and round the numbers as explained
I have the following formula which I used to round numbers specially
for example :
20.1 and 20.2 becomes 20
20.3, 20.4, 20.5,20.6,20.7 becomes 20.5
20.8 and 20.9 becomes 21
I want to convert it to use it in VBA
The fomula:::
=IF(OR(ROUND(MOD(A1;1);1)=0.1;ROUND(MOD(A1;1);1)=0.2;ROUND(MOD(A1;1);1)=0.6 ;ROUND(MOD(A1;1);1)=0.7);FLOOR(A1;0.5);CEILING(A1;0.5))
A1 in this formula should be replaced by cel in vba...
The summary is that VBA look at the cell value and round the numbers as explained