Significant Figures Function - Excel Help & Excel Macro Help
SEARCH ENTIRE SITE LOADING..

OZGRID Excel Help & Excel Best Practices Forums

Information Helpful? Why Not Donate.

SPECIALS PAGE FOR BARGAINS | BUILD YOUR GOLF SWING | FREE CUSTOM FUNCTIONS ADD-IN


Download Active Data For Excel Demo


Go Back Excel Help & Excel Macro Help > TIP, TRICKS & CODE (NO QUESTIONS) > OPEN SOURCE: Hey! That is Cool!
HOME Register Forum Help Calendar Search For Today's Posts Mark Forums Read

Reply

Significant Figures Function



Javascript DHTML Drop Down Menu Powered by dhtml-menu-builder.com

Create Excel dashboards quickly with Plug-N-Play reports.


 
Thread Tools Search this Thread
Old October 29th, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
Vertex42 Vertex42 is offline
Member
 
I'm a Spammer:
MS Office Version: 2002(XP)
Op System: Windows XP
Assumed Experience: Excel Geek
Join Date: 6th April 2004
English is 1st Language:
Posts: 25 -- Threads: 18
Significant Figures Function

After a few hours of brain crunching, I finally figured out a fairly concise Excel function for rounding to a specific number of significant digits:

=ROUND(value,sigfigs-(1+INT(LOG10(ABS(value)))))

For more information about this function, you can see the write-up on my site. I also included a corresponding custom Excel VBA function.

Rounding Significant Figures in Excel

Enjoy,
Jon
__________________
The Excel Nexus :: Excel Templates
Print [Post / Thread] Reply With Quote
Old October 30th, 2004
Derk's Avatar
Derk Derk is offline
OzMVP (The Professor)
 
I'm a Spammer: NO
MS Office Version: 2003 English
Op System: Windows XP
Assumed Experience: Expert (I wont be needing help)
Join Date: 15th April 2003
English is 1st Language: Yes
Location: USA
Posts: 7,228 -- Threads: 31
Thanks for sharing!
Print [Post / Thread] Reply With Quote
Old November 16th, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
KiwiSteve KiwiSteve is offline
Member
 
I'm a Spammer:
MS Office Version: 2000
Op System: Windows XP
Assumed Experience: Less as time goes on...
Join Date: 10th June 2004
English is 1st Language:
Location: NZ
Posts: 33 -- Threads: 3
Re: Significant Figures Function

Hi Jon

This is brilliant. Thank you.

Stephen
Print [Post / Thread] Reply With Quote
Old November 16th, 2004
iwrk4dedpr's Avatar
iwrk4dedpr iwrk4dedpr is offline
OzMVP (what..who..me???)
 
I'm a Spammer:
MS Office Version: 2000/XP/2003/2007
Op System: XP/XP Pro/Vista Home Premium
Assumed Experience: Above Average (Know VBA & All of Excel)
Join Date: 22nd January 2004
English is 1st Language: Yes
Location: Colorado Springs
Posts: 3,123 -- Threads: 150
Re: Significant Figures Function

Jon,

Pretty slick method.

Now next question. Can you make it so that if I enter two numbers that it will perform some indicated math and internally figure out the answer to the correct significant number of digits.


=sigFig(strArith,num1,num2)

Now I realize that you may have to indicate if one number was an exact number. I ask because if you use multiple calls then it would be easy to create make formula to perform calculations for say a chemistry class that always have multiple steps but sig figs are extremely important.


Regards,
Barry
Print [Post / Thread] Reply With Quote
Old November 19th, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
KiwiSteve KiwiSteve is offline
Member
 
I'm a Spammer:
MS Office Version: 2000
Op System: Windows XP
Assumed Experience: Less as time goes on...
Join Date: 10th June 2004
English is 1st Language:
Location: NZ
Posts: 33 -- Threads: 3
Re: Significant Figures Function

Hi Jon

It seems this doesn't work with some numbers. eg show 1 to 2sf should display 1.0, but shows 1 instead. Only get 1.0 if you format the no. of dps, which then prevents the correct sf appearing.
I didn't test this, but Steve Aprahamian did, and, as per usual, he got the finer detail that lesser mortals like me missed! Apart from that shortcoming, it works really well.
Cheers
Stephen
Print [Post / Thread] Reply With Quote
Old November 19th, 2004
Aaron Blood's Avatar
Aaron Blood Aaron Blood is offline
OzMVP
 
I'm a Spammer:
MS Office Version: 2003
Op System: Windows XP
Assumed Experience: Excel Jedi
Join Date: 10th February 2003
English is 1st Language:
Location: Palm Beach, Florida
Posts: 1,580 -- Threads: 48
Wink Re: Significant Figures Function

Nice work Jon.

The display isn't right... but the value seems to be fine.

Most will be content just having something to give correct values for computations.

Good point though Kiwi.
__________________
Sub All_Macros(Optional control As Variant)
Print [Post / Thread] Reply With Quote
Old December 1st, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
Vertex42 Vertex42 is offline
Member
 
I'm a Spammer:
MS Office Version: 2002(XP)
Op System: Windows XP
Assumed Experience: Excel Geek
Join Date: 6th April 2004
English is 1st Language:
Posts: 25 -- Threads: 18
Re: Significant Figures

Thank you all for your comments, especially for catching the display problem. I have added a note to my page about this. I don't see a simple solution to this problem at the moment, though.

Jon
Print [Post / Thread] Reply With Quote
Old December 1st, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
KiwiSteve KiwiSteve is offline
Member
 
I'm a Spammer:
MS Office Version: 2000
Op System: Windows XP
Assumed Experience: Less as time goes on...
Join Date: 10th June 2004
English is 1st Language:
Location: NZ
Posts: 33 -- Threads: 3
Re: Significant Figures

Steve Aprahamian suggested using =TEXT(....,"0.000"), etc to get it looking right, then using =VALUE(cell...) to handle it as a number. Sounds ok, so long as we can make the correct no. of zeros appear in the TEXT formula. Make sense?
KiwiSteve
Print [Post / Thread] Reply With Quote
Old December 1st, 2004
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
Vertex42 Vertex42 is offline
Member
 
I'm a Spammer:
MS Office Version: 2002(XP)
Op System: Windows XP
Assumed Experience: Excel Geek
Join Date: 6th April 2004
English is 1st Language:
Posts: 25 -- Threads: 18
Re: Significant Figures Function

KiwiSteve,

Thanks for the tip. I found a similar tip to use TEXT on this page.

I have since figured out a solution (albeit a very complicated one). The new formula is now posted on my site, but I've included it here also:

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
=TEXT(TEXT(value,"."&REPT("0",sigfigs)&"E+000"), "0"&REPT(".",(sigfigs-(1+INT(LOG10(ABS(value)))))>0)& REPT("0",(sigfigs-(1+INT(LOG10(ABS(value)))))* ((sigfigs-(1+INT(LOG10(ABS(value)))))>0)))

I just finished creating a corresponding VBA function, which I will post on my site soon. There was a problem in the function that was driving me crazy when the value was equal to 10, 100, 1000, etc.

It turns out that in most cases, you don't really need to use VALUE(cell), because Excel's smart enough to figure out that the string is numeric. However, I don't know how far I'd trust that.

Enjoy,
Jon
__________________
The Excel Nexus :: Excel Templates
Print [Post / Thread] Reply With Quote
Old December 1st, 2004
Dave Hawley's Avatar
Dave Hawley Dave Hawley is offline
Administrator
 
I'm a Spammer: NO
MS Office Version: 2007 English
Op System: Windows Vista
Assumed Experience: Above Average
Join Date: 24th January 2003
English is 1st Language: Yes
Location: Australia
Posts: 49,878 -- Threads: 15169
Re: Significant Figures Function

Hi Jon

You can also use +0 at the end of any formula that returns a number as text, or precede the formula with;
=-- as apposed to only =
Print [Post / Thread] Reply With Quote
Reply Lifetime Upgrade To Ad Free Styles

   « PREVIOUS A New Service for Consultants and Webmasters || Drawing on a userform NEXT »
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 22:12.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ozgrid is Not Associated With Microsoft. Ozgrid Retains the Rights to ALL Posts and Threads