Sub test()
Dim LetterCount As Long, NumFlips As Long
Dim Letters() As String
Dim Output() As String
Dim rNumber As Long, cNumber As Long
Dim Flag As Boolean
LetterCount = 2
NumFlips = 10
ReDim Letters(0 To LetterCount - 1)
Letters(0) = "T": Letters(1) = "H"
ReDim Output(1 To LetterCount ^ NumFlips, 1 To NumFlips)
For cNumber = 1 To NumFlips
Output(1, cNumber) = Letters(0)
Next cNumber
For rNumber = 2 To UBound(Output, 1)
Flag = False
For cNumber = 1 To NumFlips
If Flag Then
Output(rNumber, cNumber) = Output(rNumber - 1, cNumber)
Else
If Output(rNumber - 1, cNumber) = Letters(LetterCount - 1) Then
Output(rNumber, cNumber) = Letters(0)
Else
Output(rNumber, cNumber) = Letters(WorksheetFunction.Match(Output(rNumber - 1, cNumber), Letters, 0))
Flag = True
End If
End If
Next cNumber
Next rNumber
Range("A1").Resize(UBound(Output, 1), UBound(Output, 2)).Value = Output
End Sub