Determine Factors of Number & Counting

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi guys..

i'm looking for in excel formula to easy determine a number has factors (2 problems) :
a. how many list of factors a number?
b. counting list of factors?

numberlist of factors (expected result a)count factors (expected result b)
10{1;2;5}3
90{1;2;3;5;6;9;10;15;18;30;45;90}12
etc..

<tbody>
</tbody>

any help, greatly appreciated...

m.susanto
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Excel 2010
AB
1104
29012
Sheet7
Cell Formulas
RangeFormula
B1=SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&A1)))=0))


gets you the count, and the array can be returned with a little VBA, hang on....
 
Upvote 0

Excel 2010
A
110
290
311
413
514
622
756
Sheet8


Code:
Sub getfactors()
Dim i%, j%, lr%, a%, b%, x As Variant
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lr
a = Cells(i, 1).Value
ReDim x(a - 1)
For j = 0 To a - 1
b = a Mod (j + 1)
If b = 0 Then
x(j) = j + 1
Else
x(j) = "z"
End If
Next j
Cells(i, 3).Value = Replace(Join(x, ","), ",z", "")
Next i
End Sub


Excel 2010
ABC
1101,2,5,10
2901,2,3,5,6,9,10,15,18,30,45,90
3111,11
4131,13
5141,2,7,14
6221,2,11,22
7561,2,4,7,8,14,28,56
Sheet8
 
Upvote 0
Place a value in cell A1. In B1 enter the array formula:
Code:
=LARGE((ROUND($A$1/ROW(INDIRECT("$1:$"&$A$1)),0)=$A$1/ROW(INDIRECT("$1:$"&$A$1)))*ROW(INDIRECT("$1:$"&$A$1)),ROW(1:1))
and copy down.

Array formulas must be entered with CNTRL-SHFT-ENTER rather than just the ENTER key.
 
Last edited:
Upvote 0
Place a value in cell A1. In B1 enter the array formula:
Code:
=LARGE((ROUND($A$1/ROW(INDIRECT("$1:$"&$A$1)),0)=$A$1/ROW(INDIRECT("$1:$"&$A$1)))*ROW(INDIRECT("$1:$"&$A$1)),ROW(1:1))
and copy down.

Array formulas must be entered with CNTRL-SHFT-ENTER rather than just the ENTER key.


Excel 2010
P
190
Sheet7
Cell Formulas
RangeFormula
P1{=LARGE(((MOD($A$1,ROW(INDIRECT("1:"&$A$1)))=0)*ROW(INDIRECT("1:"&$A$1))),ROW(A1))}
Press CTRL+SHIFT+ENTER to enter array formulas.


works too, and for ascending order:


Excel 2010
R
11
Sheet7
Cell Formulas
RangeFormula
R1{=SMALL(((MOD($A$1,ROW(INDIRECT("1:"&$A$1)))=0)*ROW(INDIRECT("1:"&$A$1))),($A$1-SUMPRODUCT(--(MOD($A$1,ROW(INDIRECT("1:"&$A$1)))=0)))+ROW(A1))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Excel 2010
A
110
290
311
413
514
622
756

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8



Code:
Sub getfactors()
Dim i%, j%, lr%, a%, b%, x As Variant
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lr
a = Cells(i, 1).Value
ReDim x(a - 1)
For j = 0 To a - 1
b = a Mod (j + 1)
If b = 0 Then
x(j) = j + 1
Else
x(j) = "z"
End If
Next j
Cells(i, 3).Value = Replace(Join(x, ","), ",z", "")
Next i
End Sub

Excel 2010
ABC
1101,2,5,10
2901,2,3,5,6,9,10,15,18,30,45,90
3111,11
4131,13
5141,2,7,14
6221,2,11,22
7561,2,4,7,8,14,28,56

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8

hi sheetspread, work great!! thank you so much...
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top