Hi!
I'm new here!
I'm trying to create a VBA Macro to display 3 columns with all possible combinations of numbers between 0 and 15.
Like this:
0 0 0
0 0 1
0 0 2
0 0 3
...
15 15 15
Any skilled programmers who know how to do this?
Hi!
I'm new here!
I'm trying to create a VBA Macro to display 3 columns with all possible combinations of numbers between 0 and 15.
Like this:
0 0 0
0 0 1
0 0 2
0 0 3
...
15 15 15
Any skilled programmers who know how to do this?
Last edited by tnjaa; 12-30-2019 at 03:48 PM.
I wouldn't consider myself skilled, but how about this:
Please Login or Register to view this content.
Never stop learning!
<--- please consider *-ing !
The same but a bit faster :
PHP Code:
Sub Demo0()
Dim A%, B%, C%, R&
Application.ScreenUpdating = False
For A = 0 To 15
For B = 0 To 15
For C = 0 To 15
R = R + 1
Rows(R).Columns("A:C").Value2 = Array(A, B, C)
Next C, B, A
Application.ScreenUpdating = True
End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
As a beginner starter a bit more faster :
PHP Code:
Sub Demo1()
Const U = 15
Dim D%(), A%, B%, C%, R&
ReDim D(1 To (U + 1) ^ 3, 1 To 3)
For A = 0 To U
For B = 0 To U
For C = 0 To U
R = R + 1
D(R, 1) = A
D(R, 2) = B
D(R, 3) = C
Next C, B, A
[A1:C1].Resize(R).Value2 = D
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » !
Between both previous demonstrations there are intermediate ways like for example :
PHP Code:
Sub Demo01()
Dim R&, C, A%, B%
R = 1
C = [ROW(1:16)-1]
Application.ScreenUpdating = False
For A = 0 To 15
For B = 0 To 15
Cells(R, 1).Resize(16, 2).Value2 = Array(A, B)
Cells(R, 3).Resize(16).Value2 = C
R = R + 16
Next B, A
Application.ScreenUpdating = True
End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Last edited by Marc L; 12-31-2019 at 08:21 AM.
No No No...Come on Marc L...No loops allowed...YOU CAN DO IT...
Good Luck
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the star to left of post [Add Reputation]
Also....add a comment if you like!!!!
And remember...Mark Thread as Solved.
Excel Forum Rocks!!!
Hi sintek !
I well know any VBA code is totally useless here just using easy formulas !
Like tnjaa should surely achieved …
And I'm a bit surprised you didn't post this way.
My answer was first for harrisonland to show him first how to improve any loop procedure speed.
So for the lazy just reproducing easy Excel formulas :
PHP Code:
Sub Demo2()
With [A1:C1].Resize(16 ^ 3)
.Formula = [{"=INT((ROW()-1)/256)","=MOD(INT((ROW()-1)/16),16)","=MOD(ROW()-1,16)"}]
.Formula = .Value2
End With
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » !
Excel Crawling, skipped I did...Straight to Running I did...lolAnd I'm a bit surprised you didn't post this way
I suck at formulas...Had no excel training or inclination to utilize such...
Haha, guys. Thanks for the edification
I'm but an Excel beginner, so although I can get (some) things done, I'm grateful for learning to do things more elegantly, or efficiently!
Hope yours was a Happy New Year.
Tim
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks