I need to add a filter to my macro below;
Sub getcomb4() 'Line1
Dim a, b, c, d As Integer 'Line10
Dim count As Long 'Line20
Dim combin(2000) As String 'Line30
count = 0 'Line35
For a = 1 To 3 'Line40
For b = a + 1 To 4 'Line43
For c = b + 1 To 5 'Line46
For d = c + 1 To 6 'Line50
count = count + 1 'Line56
combin(count) = CStr(a) & "." & CStr(b) & "." & CStr(c) & "." & CStr(d) 'Line60
Next 'Line70
Next 'Line73
Next 'Line76
Next 'Line80
Range("A1").Select 'Line83
For count = 1 To 2000 'Line86
ActiveCell.Offset(count - 1, 0) = combin(count) 'Line90
Next 'Line93
End Sub 'Line96
The output is 15 lines of 4 numbers each in column A1:
1.2.3.4
1.2.3.5
1.2.3.6
1.2.4.5
1.2.4.6
1.2.5.6
1.3.4.5
1.3.4.6
1.3.5.6
1.4.5.6
2.3.4.5
2.3.4.6
2.3.5.6
2.4.5.6
3.4.5.6
The filter to be added:
Got 3 groups a , b and c
Group a got 4 nrs 1,2,3,4
Group b got 3 nrs 3,4,6
And group c got 2 nrs 4,6
I want 2 nrs from group a AND 2 nrs from group b
OR I want 2 nrs from group a AND 2 nrs from c
OR I want 2 nrs from group b AND 2 nrs from c
I should get 9 lines after running the macro:
These lines should have 3,4
Or 4,6
Or 3,4 and 4,6
Thanks
Sub getcomb4() 'Line1
Dim a, b, c, d As Integer 'Line10
Dim count As Long 'Line20
Dim combin(2000) As String 'Line30
count = 0 'Line35
For a = 1 To 3 'Line40
For b = a + 1 To 4 'Line43
For c = b + 1 To 5 'Line46
For d = c + 1 To 6 'Line50
count = count + 1 'Line56
combin(count) = CStr(a) & "." & CStr(b) & "." & CStr(c) & "." & CStr(d) 'Line60
Next 'Line70
Next 'Line73
Next 'Line76
Next 'Line80
Range("A1").Select 'Line83
For count = 1 To 2000 'Line86
ActiveCell.Offset(count - 1, 0) = combin(count) 'Line90
Next 'Line93
End Sub 'Line96
The output is 15 lines of 4 numbers each in column A1:
1.2.3.4
1.2.3.5
1.2.3.6
1.2.4.5
1.2.4.6
1.2.5.6
1.3.4.5
1.3.4.6
1.3.5.6
1.4.5.6
2.3.4.5
2.3.4.6
2.3.5.6
2.4.5.6
3.4.5.6
The filter to be added:
Got 3 groups a , b and c
Group a got 4 nrs 1,2,3,4
Group b got 3 nrs 3,4,6
And group c got 2 nrs 4,6
I want 2 nrs from group a AND 2 nrs from group b
OR I want 2 nrs from group a AND 2 nrs from c
OR I want 2 nrs from group b AND 2 nrs from c
I should get 9 lines after running the macro:
1.2.3.4 |
1.2.4.6 |
1.3.4.5 |
1.3.4.6 |
1.4.5.6 |
2.3.4.5 |
2.3.4.6 |
2.4.5.6 |
3.4.5.6 |
These lines should have 3,4
Or 4,6
Or 3,4 and 4,6
Thanks