Nombres excel
Fermé
DDiimtrri
Messages postés
10
Date d'inscription
mardi 30 mars 2010
Statut
Membre
Dernière intervention
21 avril 2010
-
Modifié par DDiimtrri le 3/04/2010 à 14:12
michel_m Messages postés 16593 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 23 mars 2023 - 3 avril 2010 à 17:33
michel_m Messages postés 16593 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 23 mars 2023 - 3 avril 2010 à 17:33
A voir également:
- Nombres excel
- Liste déroulante excel - Guide
- Formule excel - Guide
- Déplacer une colonne excel - Guide
- Aller à la ligne excel - Guide
- Tableau croisé dynamique excel - Guide
2 réponses
michel_m
Messages postés
16593
Date d'inscription
lundi 12 septembre 2005
Statut
Contributeur
Dernière intervention
23 mars 2023
3 293
3 avril 2010 à 14:33
3 avril 2010 à 14:33
bonjour
proposition de macro:
proposition de macro:
Sub tirer_5K()
Dim numeros As Collection
Dim cptr As Integer
Set numeros = New Collection
For cptr = 1 To 5000
tirage = Int(Rnd * 9000) + 1000
On Error Resume Next
numeros.Add tirage, CStr(tirage)
If Err.Number > 0 Then cptr = cptr - 1
On Error GoTo 0
Next
Application.ScreenUpdating = False
For cptr = 1 To numeros.Count
Cells(cptr, 1) = numeros(cptr)
Next
End Sub
michel_m
Messages postés
16593
Date d'inscription
lundi 12 septembre 2005
Statut
Contributeur
Dernière intervention
23 mars 2023
3 293
3 avril 2010 à 17:33
3 avril 2010 à 17:33
Oui mais le numero n'est plus numérique de type texte
macro modifiée et complètée ( quelques trucs oubliés tout à l'heure)
macro modifiée et complètée ( quelques trucs oubliés tout à l'heure)
Sub tirer_5K()
Dim numeros As Collection, tirage As String * 9
Dim tablo
Dim cptr As Integer
Set numeros = New Collection
ReDim tablo(1 To 5000)
Randomize
For cptr = 1 To 5000
'0&ENT((1+ALEA())*100000000)
tirage = "0" & Int((1 + Rnd) * 100000000)
On Error Resume Next
numeros.Add tirage, tirage
If Err.Number > 0 Then
cptr = cptr - 1
Else
tablo(cptr) = tirage
End If
On Error GoTo 0
Next
Application.ScreenUpdating = False
Range("A1:A5000") = Application.Transpose(tablo)
Set numeros = Nothing
End Sub
Modifié par michel_m le 3/04/2010 à 14:55
Sub tirer_5K() Dim numeros As Collection Dim tablo Dim cptr As Integer Set numeros = New Collection ReDim tablo(1 To 5000) For cptr = 1 To 5000 tirage = Int(Rnd * 9000) + 1000 On Error Resume Next numeros.Add tirage, CStr(tirage) If Err.Number > 0 Then cptr = cptr - 1 Else tablo(cptr) = tirage End If On Error GoTo 0 Next Application.ScreenUpdating = False Range("A1:A5000") = Application.Transpose(tablo) set numeros=nothing End Sub3 avril 2010 à 16:20
qui permet de génrerer une liste de numeros composés de chacun 9 chiffres commencant par 01 , avec ce macro ?