Jane92
Nouveau membre
Bonjour,
Merci tout d'abord pour le temps que vous m'accorderez...
Je suis bloquée depuis plusieurs jours sur le transfert des données de mon formulaire "UserForm1"vers un tableau que j'ai nommé "base" situé sur l'onglet "bdd" de mon fichier.
Voici ce que j'ai pu trouver sur le web :
Private Sub CommandButton2_Click()
With Sheets("bdd").ListObjects("base")
If .ListRows.Count = 0 Then
Range("base[[#Headers],[Nom]]").Offset(1, 0) = 1
Range("base[[#Headers],[Nom]]").Offset(1, 0) = ""
End If
If .ListRows.Count = 1 And .ListRows(1).Range.Cells(1, 1) = "" Then
Set LignTablo = Sheets("bdd").ListObjects("base").ListRows(1)
Else
Set LignTablo = Range("base").ListObject.ListRows.Add(AlwaysInsert:=True)
End If
End With
With LignTablo.Range
.Cells(1, 1) = TextBox1
.Cells(1, 2) = ComboBox1
.Cells(1, 3) = TextBox2
.Cells(1, 4) = TextBox3
.Cells(1, 5) = TextBox4
.Cells(1, 6) = TextBox5
.Cells(1, 7) = TextBox6
.Cells(1, 8) = TextBox7
.Cells(1, 9) = TextBox8
.Cells(1, 10) = TextBox9
.Cells(1, 11) = TextBox10
.Cells(1, 12) = TextBox11
.Cells(1, 13) = TextBox12
.Cells(1, 14) = TextBox13
.Cells(1, 15) = TextBox14
.Cells(1, 16) = TextBox15
.Cells(1, 17) = TextBox16
.Cells(1, 18) = TextBox17
.Cells(1, 19) = TextBox18
.Cells(1, 20) = TextBox19
.Cells(1, 21) = TextBox20
.Cells(1, 22) = TextBox18
.Cells(1, 23) = TextBox19
.Cells(1, 24) = TextBox20
.Cells(1, 25) = TextBox21
.Cells(1, 26) = TextBox22
.Cells(1, 27) = TextBox23
.Cells(1, 28) = TextBox24
.Cells(1, 29) = TextBox25
.Cells(1, 30) = TextBox26
.Cells(1, 31) = TextBox27
.Cells(1, 32) = TextBox28
.Cells(1, 33) = TextBox29
End With
'on décharge le formulaire pour qu'il soit de nouveau initialisé lors de son prochain affichage
Unload Me
End Sub
Le clic me renvoie :
"Erreur d'exécution 9
L'indice n'appartient pas à la sélection"
Pouvez-vous m'orienter ?
Merci et bonne journée à vous.
Jane
Merci tout d'abord pour le temps que vous m'accorderez...
Je suis bloquée depuis plusieurs jours sur le transfert des données de mon formulaire "UserForm1"vers un tableau que j'ai nommé "base" situé sur l'onglet "bdd" de mon fichier.
Voici ce que j'ai pu trouver sur le web :
Private Sub CommandButton2_Click()
With Sheets("bdd").ListObjects("base")
If .ListRows.Count = 0 Then
Range("base[[#Headers],[Nom]]").Offset(1, 0) = 1
Range("base[[#Headers],[Nom]]").Offset(1, 0) = ""
End If
If .ListRows.Count = 1 And .ListRows(1).Range.Cells(1, 1) = "" Then
Set LignTablo = Sheets("bdd").ListObjects("base").ListRows(1)
Else
Set LignTablo = Range("base").ListObject.ListRows.Add(AlwaysInsert:=True)
End If
End With
With LignTablo.Range
.Cells(1, 1) = TextBox1
.Cells(1, 2) = ComboBox1
.Cells(1, 3) = TextBox2
.Cells(1, 4) = TextBox3
.Cells(1, 5) = TextBox4
.Cells(1, 6) = TextBox5
.Cells(1, 7) = TextBox6
.Cells(1, 8) = TextBox7
.Cells(1, 9) = TextBox8
.Cells(1, 10) = TextBox9
.Cells(1, 11) = TextBox10
.Cells(1, 12) = TextBox11
.Cells(1, 13) = TextBox12
.Cells(1, 14) = TextBox13
.Cells(1, 15) = TextBox14
.Cells(1, 16) = TextBox15
.Cells(1, 17) = TextBox16
.Cells(1, 18) = TextBox17
.Cells(1, 19) = TextBox18
.Cells(1, 20) = TextBox19
.Cells(1, 21) = TextBox20
.Cells(1, 22) = TextBox18
.Cells(1, 23) = TextBox19
.Cells(1, 24) = TextBox20
.Cells(1, 25) = TextBox21
.Cells(1, 26) = TextBox22
.Cells(1, 27) = TextBox23
.Cells(1, 28) = TextBox24
.Cells(1, 29) = TextBox25
.Cells(1, 30) = TextBox26
.Cells(1, 31) = TextBox27
.Cells(1, 32) = TextBox28
.Cells(1, 33) = TextBox29
End With
'on décharge le formulaire pour qu'il soit de nouveau initialisé lors de son prochain affichage
Unload Me
End Sub
Le clic me renvoie :
"Erreur d'exécution 9
L'indice n'appartient pas à la sélection"
Pouvez-vous m'orienter ?
Merci et bonne journée à vous.
Jane