PDA

View Full Version : FUNCTION OR CODE TO DIVIDE NUMBERS.



pmari
11-11-2011, 11:34 PM
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

mancubus
11-12-2011, 06:23 AM
maybe stg like this...

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

pmari
11-12-2011, 06:49 AM
Dear MANCUBUS

Your code works excellently.

Many thanks for your time and effort.

Regards.

mikerickson
11-12-2011, 12:07 PM
What result do you want from 7885?

pmari
11-12-2011, 05:13 PM
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.

pmari
11-13-2011, 11:04 PM
Hi Friends,

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

Regards,PM.

shrivallabha
11-14-2011, 12:29 AM
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}.

pmari
11-15-2011, 05:13 AM
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..