+ Reply to Thread
Results 1 to 16 of 16

Logic test: Checking a number against multiple divisors

Hybrid View

JaredMcOffice Logic test: Checking a number... 08-10-2019, 09:48 AM
Bo_Ry Re: Logic test: Checking a... 08-10-2019, 10:01 AM
JaredMcOffice Re: Logic test: Checking a... 08-10-2019, 11:51 AM
JaredMcOffice Re: Logic test: Checking a... 08-10-2019, 04:19 PM
Bo_Ry Re: Logic test: Checking a... 08-10-2019, 10:37 PM
JaredMcOffice Re: Logic test: Checking a... 08-11-2019, 11:29 PM
Wurum Burner Re: Logic test: Checking a... 08-12-2019, 12:00 AM
JaredMcOffice Re: Logic test: Checking a... 08-12-2019, 05:59 PM
JeteMc Re: Logic test: Checking a... 08-15-2019, 07:19 PM
JeteMc Re: Logic test: Checking a... 08-15-2019, 09:48 PM
JaredMcOffice Re: Logic test: Checking a... 08-19-2019, 11:20 PM
Phuocam Re: Logic test: Checking a... 08-19-2019, 11:45 PM
JaredMcOffice Re: Logic test: Checking a... 08-21-2019, 07:09 PM
JeteMc Re: Logic test: Checking a... 08-21-2019, 10:08 PM
JaredMcOffice Re: Logic test: Checking a... 08-21-2019, 10:58 PM
JeteMc Re: Logic test: Checking a... 08-22-2019, 09:12 AM
  1. #1
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Logic test: Checking a number against multiple divisors

    Excel sages,

    I've got a column with a list of numbers in ascending order. I'd like to make a formula for the second column that draws out only those numbers that are not divisible by previous numbers in the column. I am not looking for prime numbers. I'm just trying to check divisibility (with no remainder) against multiple cells. Because my column A is in ascending order, I figured I could make the formula simpler by making the "divisor" any previous cells.

    I've created a mock-up to show what I'm going for:

    (Column A)
    Number list in ascending order
    5
    7
    12
    15
    20
    24
    53
    242

    Because 15, 20, and 24 are divisible by either 5 or 12, I'd like them to be dropped from Column B, and would like Column B to show:
    7
    12
    53
    242

    I tried the formula =IF(MOD(A9,(A2:A8))=0,"",A9) and pasted it in B9, but it returned #VALUE!

    I've used the MOD=0 formula before, but only using a single divisor. I imagine I'm getting the error because I'm using a range of cells as the divisor. NOTE: I'd rather not do each cell as an individual formula because although I've made my data smaller here, in the actual worksheet there are hundreds of numbers. I attached a simplified Excel worksheet here.

    Please help!

    Thanks
    J
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Logic test: Checking a number against multiple divisors

    Please try at B2
    =IF(SUMPRODUCT(N(NOT(MOD(A2,A$2:A2))))>1,"",A2)
    and drag down
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    Bo_Ry, that worked like a charm. Thanks so much!

  4. #4
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    I have a follow-up question. When I made the "sample spreadsheet" I took out any blank cells in Column A, but my original spreadsheet actually has blank cells. So the equation works until it hits a blank cell, then gives an error. Any suggestions?

    Sorry that I didn't account for that when I gave my example.

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Logic test: Checking a number against multiple divisors

    Please upload your worksheet.

  6. #6
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    See attached. As I said, I'm hoping to create one more column to the right that extracts only the numbers not divisible by the numbers above it. The formula you provided worked great but had a problem once I tried it out on a spreadsheet where the column had empty cells.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-09-2019
    Location
    San Diego, CA
    MS-Off Ver
    2013
    Posts
    5

    Re: Logic test: Checking a number against multiple divisors

    Could you just wrap the formula Bo_Ry gave you in an IF() function to check if A2 is "" first and return a "" if it is?

    IF(A2="","",(The formula Bo_Ry provided))

  8. #8
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    I tried that. No luck. It gives a VALUE! error. But thanks!

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,873

    Re: Logic test: Checking a number against multiple divisors

    Try this array entered* modification of Bo_Ry's formula: =IF(SUMPRODUCT(N(NOT(IFERROR(MOD(A2,A$2:A2),1))))>1,"",A2)
    *After pasting the formula into cell B2, simultaneously press the Ctrl, Shift and Enter keys then drag the fill handle down.
    Note that I am applying this to the file attached to post #2. To test put a blank space between any two numbers in column A.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,873

    Re: Logic test: Checking a number against multiple divisors

    The formula could be modified as follows so that it will work with the file attached to post #6: =IF(SUMPRODUCT(N(NOT(IFERROR(MOD(D2,D$2:D2),1))))>1,"",D2)
    Note that the formula should be pasted into cell E2, the Ctrl, Shift and Enter keys should be pressed then the fill handle may be double clicked to copy the formula down.
    Let us know if you have any questions.

  11. #11
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    You guys are amazing and so so helpful. Jete, I posted your second equation and it resolved the #Value! error I was getting. But it isn't ignoring numbers that have divisors. I'll post the updated Excel spreadsheet to show you.
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Logic test: Checking a number against multiple divisors

    **=IF(SUMPRODUCT(N(NOT(IFERROR(MOD(D2,D$2:D2),1))))>1,"",D2)

    ** It is an array formula, enter with Ctrl + Shift + Enter.

    Or try array formula:

    **=IF(COUNT(1/(MOD(D2,D$2:D2)=0))>1,"",D2)

  13. #13
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    Thanks, Phuocam. Unfortunately, I already tried that first formula (JeteMc provided the same one). But I tried your second formula with the same result.

    The formulas you guys provide allow me to avoid the #Value! error, but then it lists all the numbers...not just the numbers that don't have divisors. What I'm hoping is that it won't show 25, for instance, since 25 is divisible by 5, which already appeared higher up the list. But instead it lists both 5 and 25. See what I mean?

    What I was hoping to do is avoid creating a macro, since I don't know anything about macros. The only thing I can think to do would be to create a macro that removed all numerals and then compressed them into a new column without empty cells. Then I could use the formula that Bo_Ry provided. But I'm hoping to avoid that.

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,873

    Re: Logic test: Checking a number against multiple divisors

    When I opened the file I noticed that the formula had not been array entered, there were no {} around it as would be the case if Ctrl, Shift and Enter had all be pressed.
    Here is the file with the formula array activated.
    Let us know if you have any questions.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    02-04-2017
    Location
    Dayton, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Logic test: Checking a number against multiple divisors

    THAT'S IT! Thank you, all, for your patience. You are all rock stars. This was my first time trying to enter an array formula. I must've been doing it wrong. That fixed it.

  16. #16
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,873

    Re: Logic test: Checking a number against multiple divisors

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Checking multiple logic in a grid (or scatter chart)
    By Groomeister in forum Excel General
    Replies: 4
    Last Post: 01-12-2017, 11:43 AM
  2. Need Help in getting Divisors of a Number
    By sam_thesupreme in forum Excel - New Users/Basics
    Replies: 36
    Last Post: 12-28-2015, 11:31 PM
  3. [SOLVED] Simple multiple logic test help
    By rexy69 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2014, 11:31 AM
  4. [SOLVED] Multiple logic test question
    By supernovartis in forum Excel General
    Replies: 4
    Last Post: 04-04-2014, 10:10 AM
  5. [SOLVED] logic test AND OR
    By censura in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-12-2013, 05:48 AM
  6. Multiple logic test formulae
    By Jaime1234 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-11-2013, 12:27 PM
  7. Multiple conditional formatting - overcoming -ve divisors
    By Monkeyfuzzle in forum Excel General
    Replies: 1
    Last Post: 11-15-2011, 12:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1