Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 03-24-2011, 02:30 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline ** Excel Formula Windows 7 32bit ** Excel Formula Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Hi,

Quote:
Can you explain to me what each section of the formula means?
Sure.

First of all, we need a way to check if the number is a whole number. Excel doesn't have a built-in which will do that. However, it does have a few functions which can be used to remove the decimal portion of a number: the most common would be INT() and TRUNC(), but there are also various rounding functions too (such as ROUND(), ROUNDDOWN(), etc....). The logic I used was to take the number from each cell, remove the decimal portion of the number and then check to see if that is equal to the original number: if it is then the number must be a whole number:
Code:
=IF(TRUNC(A1)=A1,"A1 is a whole number","A1 is not a whole number")
I used TRUNC() rather than INT() so that this test would also work on negative numbers.


From there, it's just a case of applying the correct logic for the possible outcomes:
  • Assume that at least one number must be whole
  • Assume that we don't have to worry about empty cells
  • If A1 and B1 are whole numbers, take the minimum value.
  • Else, If A1 is whole and B1 is not whole then return A1.
  • Else, A1 is not whole so B1 must be whole, so return B1.
Code:
=IF(TRUNC(A1)=A1,IF(TRUNC(B1)=B1,MIN(A1,B1),A1),B1)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to solve this formula in excel BrOkEn_iCe Excel 2 12-21-2010 05:45 AM
excel help Formula sellspeed Excel 15 03-10-2010 10:57 AM
Needs help to find excel formula- Please aamer_1983 Excel 2 07-13-2009 01:46 AM
Excel Formula Help masoom84 Excel 1 03-07-2009 09:41 AM
** Excel Formula Excel Formula Help Shahzad Excel 1 12-07-2008 04:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft