Hallo,
lässt sich am einfachsten über ein Makro realisieren. Die Berechnung dauert allerdings etwas aufgrund des großen Zahlenraums.
Einfach den folgenden Code in ein neues Makro einfügen und ausführen lassen:
Sub teiler()
’
’ Teiler Makro
’
’
Dim id As Long
Dim teiler As Long
Dim erg As String
Dim zeile As Long
Dim intIndex As Integer
Dim max As Long
max = 1000000
On Error GoTo err_exit
Application.EnableCancelKey = xlErrorHandler
'switch of updating to speed your code & stop irritating flickering
Application.ScreenUpdating = False
'Use the Status Bar to inform user of the macro’s progress
'change the cursor to hourglass
Application.Cursor = xlWait
’ makes sure that the statusbar is visible
Application.DisplayStatusBar = True
'add your message to status bar
Application.StatusBar = „Formatting Report…“
erg = „“
MsgBox „Funktion kann über Tastenkombination + ESC abgebrochen werden“
For id = 1 To max
erg = „“
zeile = id + 1
Range(„A“ & zeile).FormulaR1C1 = id
For teiler = 1 To id
If id Mod teiler = 0 Then
If erg = „“ Then
erg = teiler
Else
erg = erg & ", " & teiler
End If
End If
If id Mod 100 = 0 Then Application.StatusBar = "Aktuell bearbeitet " & id & " - ca. " & Abs(id / max * 100) & „%. Abruch durch + ESC möglich.“
DoEvents
Next teiler
Range(„B“ & zeile).FormulaR1C1 = erg
Range(„C“ & zeile).FormulaR1C1 = Len(erg) - Len(Replace(erg, ", ", " ")) + 1
Next id
MsgBox „Fertig“
sub_exit:
'restore default cursor
Application.Cursor = xlDefault
’ gives control of the statusbar back to the programme
Application.StatusBar = False
Application.ScreenUpdating = True
Application.EnableCancelKey = xlInterrupt
Exit Sub
err_exit:
If Err.Number = 18 Then
If MsgBox(„Wirklich abbrechen?“, vbCritical + vbYesNo, _
„Abbruch“) = vbNo Then Resume
Else
MsgBox "Fehler " & CStr(Err.Number) & vbLf & vbLf & _
Err.Description, vbCritical, „Fehler“
End If
Resume sub_exit
End Sub
Viele Grüße
Chris