We have the need to round the contents of various different cells to 3 significant figures. For the sake of this discussion lets use a value of 0.7567 that is in range A1
If we use the following to set the value of a cell to 3 decimal places in a sheet, the line does just what we want (rounds any number to 3 sig figs.):
= ROUND(A1, 3 - (1 + INT(LOG10(ABS(A1))))) -----> This works great in a sheet.
If we use the next line of code:
The numeral 3 in the code above is for significant figures.Please Login or Register to view this content.
Using this line of code in VBA we get the following error: Compile error: Sub or function not defined and Log10 is highlighted as the cause of the error. It appears Log10 doesn't work in VBA.
If anyone has an idea how we could get this line of code to work in VBA, it would be greatly appreciated.
This table shows an example of how we deal with significant figures.
Starting Value Value need from starting value
0.7567 0.757
1.7567 1.76
10.7567 10.8
100.7567 101
1075.7567 1080
10757.7567 10800
107576.7567 108000
Thanks for looking, and we appreciate any help!!!!
Bookmarks