Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
1288to1292
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Alle Teiler einer Zahl

Alle Teiler einer Zahl
23.12.2012 10:09:45
Alifa
Hallo,
in der Spalte A sind 90 Zeilen, mit 4- bis 6-stelligen Zahlen. Wie kann ich mit einem Makro erreichen, dass jeweils neben jede Zahl,(Spalte B) alle Teiler geschrieben werden?

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Alle Teiler einer Zahl
23.12.2012 10:18:28
Hajo_Zi
man könnte vermuten Du möchtest nur Teiler haben die ein ganzzahliges Ergebnis haben und wo der Teiler auch ganzzahlig ist?
Ansonsten reichen die Spalten nicht.

AW: Alle Teiler einer Zahl
23.12.2012 10:27:20
Hajo_Zi
fallls meine Annahmen zutreffen? Option Explicit Sub Teiler() Dim LoLetzte As Long Dim LoI As Long Dim LoJ As Long Dim InSpalte As Integer LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 1)), Cells(Rows.Count, 1).End(xlUp).Row, Rows. _ Count) For LoI = 1 To LoLetzte If IsNumeric(Cells(LoI, 1)) Then InSpalte = 2 For LoJ = Cells(LoI, 1) To 1 Step -1 If Cells(LoI, 1) / LoJ = CInt(Cells(LoI, 1) / LoJ) Then Cells(LoI, InSpalte) = LoJ InSpalte = InSpalte + 1 End If Next LoJ End If Next LoI End Sub Gruß Hajo

Anzeige
AW: mit Fehlerbehandlung
23.12.2012 10:29:47
Hajo_Zi

Option Explicit
Sub Teiler()
Dim LoLetzte As Long
Dim LoI As Long
Dim LoJ As Long
Dim InSpalte As Integer
LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 1)), Cells(Rows.Count, 1).End(xlUp).Row, Rows. _
Count)
For LoI = 1 To LoLetzte
If IsNumeric(Cells(LoI, 1)) Then
InSpalte = 2
For LoJ = Cells(LoI, 1) To 1 Step -1
If Cells(LoI, 1) / LoJ = CInt(Cells(LoI, 1) / LoJ) Then
Cells(LoI, InSpalte) = LoJ
InSpalte = InSpalte + 1
If InSpalte > Columns.Count Then
MsgBox "nicht genügend Spalten"
Exit For
End If
End If
Next LoJ
End If
Next LoI
End Sub
Gruß Hajo

Anzeige
AW: Alle Teiler einer Zahl
23.12.2012 10:38:59
{Boris}
Hi Hajo,
Du möchtest nur Teiler haben die ein ganzzahliges Ergebnis haben und wo der Teiler auch ganzzahlig ist?
Teiler sind ex definitione IMMER ganzzahlig - sonst wären es kein Teiler.
VG, Boris

AW: Alle Teiler einer Zahl
23.12.2012 12:18:08
Gerd
Hallo Erhard!
Sub test()
Dim X As Long, i As Long, strDiv As String
For Z = 1 To 90
X = Cells(Z, 1)
strDiv = ""
For i = 2 To Int(X / 2)
If X Mod i = 0 Then strDiv = strDiv & ", " & i
Next
Cells(Z, 2) = Mid$(strDiv, 3)
Next
End Sub

Gruß Gerd

Anzeige
AW: Alle Teiler einer Zahl
24.12.2012 12:45:50
ransi
Hallo
Und hier noch "was schnelles":
Tabelle1

 AB
193641, 9364, 2, 4682, 4, 2341
2500331, 50033
3764861, 76486, 2, 38243, 167, 458, 229, 334
41175451, 117545, 5, 23509
52276711, 227671
62646711, 264671, 11, 24061
72914881, 291488, 2, 145744, 4, 72872, 8, 36436, 16, 18218, 32, 9109
83261841, 326184, 2, 163092, 3, 108728, 4, 81546, 6, 54364, 8, 40773, 12, 27182, 24, 13591
93589311, 358931
103851741, 385174, 2, 192587
113915451, 391545, 3, 130515, 5, 78309, 7, 55935, 9, 43505, 11, 35595, 15, 26103, 21, 18645, 33, 11865, 35, 11187, 45, 8701, 55, 7119, 63, 6215, 77, 5085, 99, 3955, 105, 3729, 113, 3465, 165, 2373, 231, 1695, 315, 1243, 339, 1155, 385, 1017, 495, 791, 565, 693
123986131, 398613, 3, 132871, 23, 17331, 53, 7521, 69, 5777, 109, 3657, 159, 2507, 327, 1219
134460131, 446013, 3, 148671, 9, 49557, 27, 16519
144771001, 477100, 2, 238550, 4, 119275, 5, 95420, 10, 47710, 13, 36700, 20, 23855, 25, 19084, 26, 18350, 50, 9542, 52, 9175, 65, 7340, 100, 4771, 130, 3670, 260, 1835, 325, 1468, 367, 1300, 650, 734
154890481, 489048, 2, 244524, 3, 163016, 4, 122262, 6, 81508, 7, 69864, 8, 61131, 12, 40754, 14, 34932, 21, 23288, 24, 20377, 28, 17466, 41, 11928, 42, 11644, 56, 8733, 71, 6888, 82, 5964, 84, 5822, 123, 3976, 142, 3444, 164, 2982, 168, 2911, 213, 2296, 246, 1988, 284, 1722, 287, 1704, 328, 1491, 426, 1148, 492, 994, 497, 984, 568, 861, 574, 852
165528511, 552851, 13, 42527, 23, 24037, 43, 12857, 299, 1849, 559, 989
175570121, 557012, 2, 278506, 4, 139253, 131, 4252, 262, 2126, 524, 1063
185902851, 590285, 5, 118057
196456691, 645669, 3, 215223, 9, 71741
206537861, 653786, 2, 326893, 7, 93398, 14, 46699, 17, 38458, 34, 19229, 41, 15946, 67, 9758, 82, 7973, 119, 5494, 134, 4879, 238, 2747, 287, 2278, 469, 1394, 574, 1139, 697, 938
217411301, 741130, 2, 370565, 5, 148226, 10, 74113, 13, 57010, 26, 28505, 65, 11402, 130, 5701
227865601, 786560, 2, 393280, 4, 196640, 5, 157312, 8, 98320, 10, 78656, 16, 49160, 20, 39328, 32, 24580, 40, 19664, 64, 12290, 80, 9832, 128, 6145, 160, 4916, 320, 2458, 640, 1229
238005951, 800595, 3, 266865, 5, 160119, 9, 88955, 15, 53373, 45, 17791
248045621, 804562, 2, 402281, 11, 73142, 22, 36571
258252111, 825211, 37, 22303
268271791, 827179, 239, 3461
278437321, 843732, 2, 421866, 3, 281244, 4, 210933, 6, 140622, 9, 93748, 12, 70311, 18, 46874, 23, 36684, 36, 23437, 46, 18342, 69, 12228, 92, 9171, 138, 6114, 207, 4076, 276, 3057, 414, 2038, 828, 1019
288845861, 884586, 2, 442293, 3, 294862, 6, 147431, 379, 2334, 389, 2274, 758, 1167, 778, 1137
299545871, 954587, 499, 1913
309561611, 956161, 41, 23321

Formeln der Tabelle
ZelleFormel
B1=machs(A1)


Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit




Public Function machs(zahl)
    Dim lngCount As Long
    Dim Obergrenze As Long
    Dim lngIndex As Long
    Redim arr(lngIndex)
    Obergrenze = zahl
    Do
        lngCount = lngCount + 1
        If lngCount >= Obergrenze Then Exit Do
        If zahl Mod lngCount = 0 Then
            lngIndex = lngIndex + 2
            Redim Preserve arr(lngIndex - 1)
            arr(lngIndex - 2) = lngCount
            Obergrenze = zahl / lngCount
            arr(lngIndex - 1) = Obergrenze
        End If
    Loop
    machs = Join(arr, ", ")
End Function


ransi
Anzeige

16 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige