View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default Function for combinations

you can increase performance by removing ".Select"
it is a macro "Excel4" that i found in my archives and i translated it as such in vba

--
isabelle



Le 2012-01-19 23:54, isabelle a écrit :
hi Robert,

this is an example to get started


Sub combin()
Dim nbchiff As Integer, nb As Integer, plage As Range, cel As Range, list
list = Array(15, 23, 26, 29, 40)
nbchiff = InputBox("nombre de chiffre ?")
For nb = 1 To nbchiff
Cells(nb, 1) = (0 + list(nb - 1))
Next
Cells(nbchiff, 1).Select
bi:
Set plage = Range(Cells(1, ActiveCell.Column), ActiveCell)
plage.Cells(1).Offset(0, 1).Select
For Each cel In plage
For nb = 1 To nbchiff
ActiveCell = cel & (",") & (1 + list(nb - 1))
ActiveCell.Offset(1, 0).Select
Next nb
Next cel
ActiveCell.Offset(-1, 0).Select
If ActiveCell.Column < nbchiff Then GoTo bi
End Sub