Hi grantor,
Have a look on the attachment with simple (but probably effective enough for this purpose macro).
Sub prepare()
Dim outrow As Long, t As Double
outrow = 10
t = Timer
Application.ScreenUpdating = False
Call combine("ABCDEFGHIJKLMNOPQRS", "", outrow)
Range("H10:I10").AutoFill Destination:=Range("H10:I978")
MsgBox "Finshed in " & Format(Timer - t, "#.0") & " s"
End Sub
Sub combine(source As String, ready As String, outrow As Long)
Dim i As Byte
If Len(ready) = 3 Then
Cells(outrow, 1) = ready
For i = 1 To 3
Cells(outrow, i + 1) = Cells(1, Mid(ready, i, 1))
Cells(outrow, i + 4) = Cells(2, Mid(ready, i, 1))
Next i
outrow = outrow + 1
Else
For i = 1 To Len(source)
If Len(source) - i + Len(ready) + 1 >= 3 Then _
Call combine(Mid(source, i + 1), ready & Mid(source, i, 1), outrow)
Next i
End If
End Sub
I followed your described input data layout. the output is 969 rows with linest for all combination of triplets of your data.
I skipped in the macro the part about random sheets because I do not think I understood it well.
Of course you can comment or delete out rows:
For i = 1 To 3
Cells(outrow, i + 1) = Cells(1, Mid(ready, i, 1))
Cells(outrow, i + 4) = Cells(2, Mid(ready, i, 1))
Next i
and use for instance INDIRECT function with RAND as input For instance see B10:
Formula:
=INDIRECT("Arkusz"&ROUNDUP(RAND()*3,0)&"!"&MID($A10,COLUMN(A1),1)&2)
and next cells in attachment (before running unmodified macro). And after macro - copy such INDIRECT formulas down. - you will introduce some stochastics into data picking process.
Just for the future
Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.
Remember to desensitize the data.
Click on GO ADVANCED and use the paperclip icon to open the upload window.
View Pic
Bookmarks