Sunday, July 24, 2011

Generate All Possible Combination :

If you want to Generate All Possible Combination of 9 Digit (1 to 9) , You can use this :



Sub ss()
For One = 1 To 9
    For Two = 1 To 9
        For three = 1 To 9
            For Four = 1 To 9
                For Five = 1 To 9
                    For Six = 1 To 9
                        For Seven = 1 To 9
                            For Eight = 1 To 9
                                For Nine = 1 To 9
                                    ActiveCell.Value = One & Two & three & Four & Five          & Six & Seven & Eight & Nine
                                    If ActiveCell.Row <> 1048576 Then
                                    ActiveCell.Offset(1, 0).Select
                                    Else
                                    ActiveCell.Offset(1, 1).Select
                                    End If
                                   
                                Next
                            Next
                        Next
                    Next
                Next
            Next
        Next
    Next
Next
End Sub

No comments: