The
image shows the rows and columns
I have code to loop the value like in first take value from column no 1,1,1,1,1,1,1,1,1,1,1,1 then take value from 1,1,1,1,1,1,1,1,1,1,1,2 then 1,1,1,1,1,1,1,1,1,1,1,3 then 1,1,1,1,1,1,1,1,1,1,2,1 then 1,1,1,1,1,1,1,1,1,1,2,2 then 1,1,1,1,1,1,1,1,1,1,2,3 then 1,1,1,1,1,1,1,1,1,1,3,1 and so on....
What I have tried:
The code is
Option Explicit
Sub CountBase3()
Dim R As Range
Set R = Range("F2:H13")
Dim Rows As Long, Columns As Long, Maxcount As Long
Rows = R.Rows.Count()
Columns = R.Columns.Count()
Maxcount = Columns ^ Rows
Debug.Print ("Maxcount=" & Maxcount)
Dim data As Variant
data = R
Dim counter As Long, row As Long, column As Long, counterShifted As Long
Dim Values()
ReDim Values(Rows)
For counter = 0 To 8
counterShifted = counter
For row = Rows To 1 Step -1
column = counterShifted Mod Columns + 1
Values(row) = data(row, column)
counterShifted = counterShifted \ Columns
Next row
Debug.Print ("Set " & counter + 1)
For row = 1 To Rows
Debug.Print (Values(row));
Next row
Debug.Print ("")
Next counter
End Sub
and
output is
Maxcount=531441
Set 1
700 500 500 500 450 400 400 450 300 250 200 100
Set 2
700 500 500 500 450 400 400 450 300 250 200 150
Set 3
700 500 500 500 450 400 400 450 300 250 200 200
Set 4
700 500 500 500 450 400 400 450 300 250 250 100
Set 5
700 500 500 500 450 400 400 450 300 250 250 150
Set 6
700 500 500 500 450 400 400 450 300 250 250 200
Set 7
700 500 500 500 450 400 400 450 300 250 300 100
Set 8
700 500 500 500 450 400 400 450 300 250 300 150
Set 9
700 500 500 500 450 400 400 450 300 250 300 200
so number of possibility is 3^12 = 531441 witch is large and time consuming so if have to find like possibility no 50000 or any possibility number within 531441 so if any idea how to do it