+ Reply to Thread
Results 1 to 26 of 26

Find first number that is smaller than some number but divisible with other number

  1. #1
    Registered User
    Join Date
    07-20-2019
    Location
    Serbia
    MS-Off Ver
    2016
    Posts
    13

    Find first number that is smaller than some number but divisible with other number

    Hello, please help me with this one:

    Excel should find first number smaller than input number, and to be divisible with some specified number.

    For example, Cell A1 number 212
    For example, Cell B1 number 20
    C1 should show result 200 (first number smaller than 212 and divisible with 20)

    Thanks in advance

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Find first number that is smaller than some number but divisible with other number

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Find first number that is smaller than some number but divisible with other number

    Use this:

    =A1-SUMPRODUCT(--(MOD((A1-ROW(1:25)),20)=0)*ROW(1:25))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    07-20-2019
    Location
    Serbia
    MS-Off Ver
    2016
    Posts
    13

    Re: Find first number that is smaller than some number but divisible with other number

    That is just great, thank you very much!
    I love this forum already

    I tried first formula and it works. Is there any difference and benefit to use second one?

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Find first number that is smaller than some number but divisible with other number

    None. But check witg a few other mumbers. I now think both fail. Im out looking at carpets now. Back later.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    Should it not be this?

    =INT(A1/A2)*A2

    Excel 2016 (Windows) 32 bit
    A
    1
    212
    2
    20
    3
    200
    Sheet: Sheet1
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find first number that is smaller than some number but divisible with other number

    Wondering why nobody has suggested
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    Because nobody thought of it ... Until now!!!

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Find first number that is smaller than some number but divisible with other number

    Or perhaps simply because we like to overcomplicate things

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    No, I can honestly say that I hadn't thought of it. My menopausal brain doesn't remember these nuggets unless I write them down.

    Correct me if I'm wrong, but I believe the FLOOR function is calculating what I suggested, isn't it?

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Find first number that is smaller than some number but divisible with other number

    If you have A1=200 & B=20, both
    =INT(A1/B1)*B1
    and
    =FLOOR(A1,B1)
    will return 200, but the OP wanted
    first number smaller than input number, and to be divisible with some specified number
    So using Jason's idea it would be
    =FLOOR(A1-1,B1)

  12. #12
    Registered User
    Join Date
    07-20-2019
    Location
    Serbia
    MS-Off Ver
    2016
    Posts
    13

    Re: Find first number that is smaller than some number but divisible with other number

    Thanks all.
    I checked first formula:=INT((A1-1)/B1)*B1, in many different cases and it seems to work. I already implemented it in my work so won't change, I suppose....

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189
    I was wondering about that, Fluff, but went with what I thought was more likely to be correct rather than looking at the question as literal.

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Find first number that is smaller than some number but divisible with other number

    Quote Originally Posted by beard View Post
    Thanks all.
    You're welcome & thanks for the feedback.

    @Jason
    I know what you mean & your idea was definitely the simpler solution.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Find first number that is smaller than some number but divisible with other number

    I just overcomplicated it... as usual... and got it incorrect at the same time!!

    However, do check out Fluff13's formula with 200 (or any multiple of 20) as the input number. It fails and falls over. Use FLOOR or Ali's suggestion.

  17. #17
    Registered User
    Join Date
    07-20-2019
    Location
    Serbia
    MS-Off Ver
    2016
    Posts
    13

    Re: Find first number that is smaller than some number but divisible with other number

    Quote Originally Posted by Glenn Kennedy View Post
    I just overcomplicated it... as usual... and got it incorrect at the same time!!

    However, do check out Fluff13's formula with 200 (or any multiple of 20) as the input number. It fails and falls over. Use FLOOR or Ali's suggestion.
    I checked Fluff13 formula with 200 and 20 and result is 180, which is ok. Am I missing something?

  18. #18
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Find first number that is smaller than some number but divisible with other number

    No. You're not. Everyone else misread your request. Time I was put down, I think....

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    How is 180 correct? You said this:

    Excel should find first number smaller than input number, and to be divisible with some specified number.
    You then told us that the answer you wanted with 212 and 20 as the inputs was 200. This is not 180. 180 is not the first number smaller than 212 to meet your criteria.

    Everyone else misread your request.
    I read what was there.

  20. #20
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Find first number that is smaller than some number but divisible with other number

    Read Post 16-17, Ali

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    I have read posts #16 and #17 again and am none the wiser.

    The input number is 212.
    The divisor is 20.
    200 is divisible by 20 and smaller than 212.
    180 is divisible by 20 and smaller than 212, but also smaller than 200.

    Therefore 200 is the first number smaller than the input number (212) that is divisible by 20.

    200 is NOT the input number - it's the result. It is also the result that the OP specifically said they were looking for in the opening post.

    If that's not what the OP meant, then they did not express themselves very well at all.

  22. #22
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Find first number that is smaller than some number but divisible with other number

    If the input number is 200 & the divisor is 20, the OP wanted 180 returned, rather than 200

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    How did you work that out? Here's what he said:

    For example, Cell A1 number 212
    For example, Cell B1 number 20
    C1 should show result 200 (first number smaller than 212 and divisible with 20)
    Input: 212
    Input: 20

    Desired result: 200


  24. #24
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Find first number that is smaller than some number but divisible with other number

    Glenn was making the point that IF the input was 200 my formula would return 180 not 200.

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Find first number that is smaller than some number but divisible with other number

    I am completely confused, probably because of this in post #17:

    I checked Fluff13 formula with 200 and 20 and result is 180, which is ok.
    Never mind - I give in!

  26. #26
    Registered User
    Join Date
    07-20-2019
    Location
    Serbia
    MS-Off Ver
    2016
    Posts
    13

    Re: Find first number that is smaller than some number but divisible with other number

    My English is bad, and so my terminology, sorry.
    Hope this shows what I wanted and got:
    Capture.JPG

+ 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] Setting a minimum number by a divisible number.
    By ILaRusic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-29-2019, 12:21 PM
  2. Replies: 4
    Last Post: 09-10-2016, 06:56 AM
  3. [SOLVED] If not divisible, find a divislbe number
    By olemgaa in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-04-2015, 05:51 AM
  4. [SOLVED] How to check if number is divisible by 6
    By jmilliken in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-09-2014, 02:00 PM
  5. selecting divisible by a number
    By bkabue in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-11-2014, 10:40 AM
  6. How to find the smaller number in the list
    By kishoremcp in forum Excel General
    Replies: 3
    Last Post: 01-24-2012, 05:21 PM
  7. Replies: 7
    Last Post: 12-18-2008, 07:34 PM

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