Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA round percents

Tags:

excel

vba

I have following vba command in excel

wbImportFrom.Sheets("Sheet 3").Cells(n, 8).Value

which returns me for example this

0,128888889

I can turn it into percent

Format(wbImportFrom.Sheets("Sheet 3").Cells(n, 8).Value,"Percent")
-- returns 13.00 %

How can i round the percent number to integer (13 %) ? Other examples

0,057 => 6%
0,088571429 => 9%
0,15 => 15%
0,048461538 => 5%
0,128888889 => 13%
0,03 => 3%
0 => 0%

I tried play with Round and Val functions but it simply does not work to me :p

like image 225
Muflix Avatar asked Jan 10 '23 22:01

Muflix


1 Answers

Whenever in doubt, record a macro :)

Is this what you are trying?

Format(wbImportFrom.Sheets("Sheet 3").Cells(n, 8).Value,"0%")
like image 177
Siddharth Rout Avatar answered Jan 16 '23 06:01

Siddharth Rout