Consulting

Results 1 to 8 of 8

Thread: FUNCTION OR CODE TO DIVIDE NUMBERS.

  1. #1
    VBAX Regular
    Joined
    Sep 2011
    Posts
    29
    Location

    FUNCTION OR CODE TO DIVIDE NUMBERS.

    Hi Friends,

    I need to divide numbers in one column with 83,95,99,112 and retain only result with whole number.

    While dividing the Number in base column with 83 or 95 or 99 or 112, only one result will come as whole number. I hope explained the scenario.

    Please look onto this, any help highly appreciated.

    With Best Regards

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    maybe stg like this...

    [VBA]Sub test()

    Dim LastRow As Long, lrow As Long, baseCol As Long, i As Long
    Dim arr, ret

    arr = Array(83, 95, 99, 112)
    baseCol = 1
    LastRow = Cells(Rows.Count, baseCol).End(xlUp).Row

    For lrow = 2 To LastRow
    For i = LBound(arr) To UBound(arr)
    ret = Cells(lrow, baseCol) / arr(i)
    If (ret - Int(ret)) = 0 Then
    Cells(lrow, baseCol + 1) = ret
    Exit For
    End If
    Next i
    Next lrow

    End Sub
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Sep 2011
    Posts
    29
    Location
    Dear MANCUBUS

    Your code works excellently.

    Many thanks for your time and effort.

    Regards.

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    What result do you want from 7885?

  5. #5
    VBAX Regular
    Joined
    Sep 2011
    Posts
    29
    Location
    Hi mikerickson,

    you are right ,7885 will divided by both 83 & 95.

    I am trying make sets from these ordered qty. set consists with all the 4 numbers i mentioned.

    When an order comes with 7885, or with 8217 , to be calculated manually. Normally single order qty will not come more than 50 sets for this item.

    Thanks for consideration.

  6. #6
    VBAX Regular
    Joined
    Sep 2011
    Posts
    29
    Location
    Hi Friends,

    How to make this thread title as SOLVED, Anybody pl. help.

    Regards,PM.

  7. #7
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    At Top Right of your post 1, you will see an option named "Thread Tool" with dropdown. There is an option named "Mark as solved" which you need select.

    But it doesn't appear in all browsers (e.g. Google Chrome, I do not know about any latest update) but it appears in Internet Explorer {See my signature}.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  8. #8
    VBAX Regular
    Joined
    Sep 2011
    Posts
    29
    Location
    Quote Originally Posted by shrivallabha
    At Top Right of your post 1, you will see an option named "Thread Tool" with dropdown. There is an option named "Mark as solved" which you need select.

    But it doesn't appear in all browsers (e.g. Google Chrome, I do not know about any latest update) but it appears in Internet Explorer {See my signature}.
    Even in Windows explorer "Solved" option not available. Any ideas..

Posting Permissions

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