Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Privacywetgeving
Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.
Option Explicit
Sub combinaties()
Dim r As Range
Dim iUpperLimit As Integer
Dim s
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim q As Integer, iSum As Integer
Dim lCombos As Long
s = Timer
For Each r In Range("B9:B25")
iUpperLimit = Int(r.Value / WorksheetFunction.Min(Range("C8:F8")))
For i = 0 To iUpperLimit
For j = 0 To iUpperLimit
For k = 0 To iUpperLimit
For l = 0 To iUpperLimit
lCombos = lCombos + 1
If lCombos Mod 10 = 0 Then Application.StatusBar = lCombos & " combinaties gecheckt"
iSum = i * Range("C8").Value + j * Range("D8").Value + k * Range("E8").Value + l * Range("F8").Value
If iSum = r.Value And WorksheetFunction.CountIf(Columns(7), CStr(i & j & k & l)) = 0 Then
For q = 1 To 4
If Choose(q, i, j, k, l) Then
r.Offset(, q).Value = Range("C8:F8").Cells(q).Value & "x" & Choose(q, i, j, k, l)
r.Offset(, 5).Value = CStr(i & j & k & l)
End If
Next
GoTo here
End If
Next: Next: Next: Next
here:
Next
MsgBox Int(Timer - s) & " sec.", vbInformation
Application.StatusBar = False
End Sub
Sub combinaties()
Dim r As Range
Dim rSums As Range, rNumbers As Range
Dim iUpperLimit As Integer
Dim s
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim q As Integer, iSum As Integer
Dim lCombos As Long
s = Timer
[B] Set rSums = Range("B9:B25")
Set rNumbers = Range("C8:F8")[/B]
For Each r In rSums
iUpperLimit = Int(r.Value / WorksheetFunction.Min(rNumbers))
For i = 0 To iUpperLimit
For j = 0 To iUpperLimit
For k = 0 To iUpperLimit
For l = 0 To iUpperLimit
lCombos = lCombos + 1
If lCombos Mod 10 = 0 Then Application.StatusBar = lCombos & " combinaties gecheckt"
[B]iSum = WorksheetFunction.SumProduct(rNumbers, Array(i, j, k, l))[/B]
If iSum = r.Value And WorksheetFunction.CountIf(Columns(7), CStr(i & j & k & l)) = 0 Then
For q = 1 To 4
If Choose(q, i, j, k, l) Then
r.Offset(, q).Value = rNumbers.Cells(q).Value & "x" & Choose(q, i, j, k, l)
r.Offset(, 5).Value = CStr(i & j & k & l)
End If
Next
GoTo here
End If
Next: Next: Next: Next
here:
Next
[B] MsgBox Round(Timer - s, 2) & " sec.", vbInformation[/B]
Application.StatusBar = False
End Sub
Wigi, ik snap het gebruik van die code niet helemaal.
Volgends mij is dat niet wat Jack zoekt!
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.