Affichage CheckBox Userform d'un Identifiant

CATPLUS

XLDnaute Junior
Bonjour
J'avais sollicité votre aide il y a fort longtemps avec succés

https://www.excel-downloads.com/threads/combox.163838/#post-990912

Depuis la retraite j'ai fait évolué ce projet
Enregistrement
L'Userform contient des ComboBox, TextBox, CheckBox et Un Bouton
Cette partie fonctionne sans aucun probléme. Les données sont logées dans les cellules correspondantes
J'ai rajouté 2 boutons
Recherche (idem fonctionnement OK)
Modification (c'est là le soucis)

Private Function My_text()

ComboBox1.Text = ActiveCell.Text
TextBox3.Text = ActiveCell.Offset(0, 1).Text
TextBox2.Text = ActiveCell.Offset(0, 2).Text
ComboBox2.Text = ActiveCell.Offset(0, 3).Text
ComboBox3.Text = ActiveCell.Offset(0, 4).Text
ComboBox4.Text = ActiveCell.Offset(0, 5).Text
TextBox7.Text = ActiveCell.Offset(0, 6).Text
TextBox8.Text = ActiveCell.Offset(0, 7).Text
TextBox9.Text = ActiveCell.Offset(0, 8).Text
ComboBox5.Text = ActiveCell.Offset(0, 11).Text
ComboBox6.Text = ActiveCell.Offset(0, 12).Text
CheckBox1.Value = ActiveCell.Offset(0, 14).Value
CheckBox2.Value = ActiveCell.Offset(0, 16).Value
CheckBox3.Value = ActiveCell.Offset(0, 17).Value
CheckBox4.Value = ActiveCell.Offset(0, 18).Value
CheckBox5.Value = ActiveCell.Offset(0, 19).Value
CheckBox6.Value = ActiveCell.Offset(0, 20).Value
OptionButton1.Value = ActiveCell.Offset(0, 15).Value
OptionButton2.Value = ActiveCell.Offset(0, 10).Value

End Function

A l'affichage les ComboBox et TextBox s'affiche sans probléme mais les CheckBox et le Bouton font n'importe quoi (s'il n'y a rien dans la cellule => affichage quand même, en gris etc...)
J'ai essayé avec un
If cellule then .....
Je ne trouve pas la solution
Merci de m'aider
Cordialement





 

Pièces jointes

  • Presse-papiers-2.jpg
    Presse-papiers-2.jpg
    49.7 KB · Affichages: 72
  • Presse-papiers-1.jpg
    Presse-papiers-1.jpg
    149.2 KB · Affichages: 76

Lone-wolf

XLDnaute Barbatruc
Bonjour CATPLUS :), Bruno :)

Tu voudrais bien mettre le fichier en quesion en PJ s'il-te-plaît. Sinon un exemple, il faudra adapter les colonnes.

VB:
Private Sub ComboBoxX()
If ComboBoxX.Text <> "" Then Call Recherche
End Sub

Private Sub Recherche()
Dim rw

With Sheets("Parc1")   'C'est la combo de recherche
rw = Application.Match(ComboBoxX, .Columns(2), 0)
TextBox1 = .Cells(rw, 2)
TextBox2 = .Cells(rw, 3)
TextBox3 = .Cells(rw, 4)
TextBox7 = .Cells(rw, 7)
TextBox8 = .Cells(rw, 8)
TextBox9 = .Cells(rw, 9)

ComboBox1 = .Cells(rw, 10)
ComboBox2 = .Cells(rw, 11)
ComboBox3 = .Cells(rw, 12)
ComboBox4 = .Cells(rw, 13)
ComboBox5 = .Cells(rw, 14)
ComboBox6 = .Cells(rw, 15)
CheckBox1.Value = .Cells(rw, 16).Value
CheckBox2.Value = .Cells(rw, 17).Value
CheckBox3.Value = .Cells(rw, 18).Value
CheckBox4.Value = .Cells(rw, 19).Value
CheckBox5.Value = .Cells(rw, 20).Value
CheckBox6.Value = .Cells(rw, 21).Value
OptionButton1.Value = .Cells(rw, 22).Value
OptionButton2.Value = .Cells(rw, 23).Value
End With
End Sub

Et pour modifier une ligne avec le bouton Modifier, il faudra faire le contraire, exemple:
.Cells(rw, 2) = TextBox1
.Cells(rw, 3) = TextBox2
.Cells(rw, 4) = TextBox3
Etc.
 
Dernière édition:

Discussions similaires

H
Réponses
19
Affichages
5 K

Statistiques des forums

Discussions
312 030
Messages
2 084 780
Membres
102 664
dernier inscrit
LudovicF