OVH Cloud OVH Cloud

Ajouter dans une cellule les checkbox avec un + au milieu

5 réponses
Avatar
Michel
Bonjour à toutes et tous
J'ai un userform avec ce code :
Je souhaite que si l'utilisateur coche par exemple le checkbox1 et le 3
dans la cellule active, il y a : alpha + charly
merci et bonne soirée
Michel

Private Sub CommandButton1_Click()
If CheckBox1 Then
ActiveCell.Value = "alpha"
End If
If CheckBox2 Then
ActiveCell.Value = "bêta"
End If
If CheckBox3 Then
ActiveCell.Value = "charly"
End If
If CheckBox4 Then
ActiveCell.Value = "echo"
End If
End Sub

5 réponses

Avatar
FxM
Bonjour à toutes et tous
J'ai un userform avec ce code :
Je souhaite que si l'utilisateur coche par exemple le checkbox1 et le 3
dans la cellule active, il y a : alpha + charly
merci et bonne soirée
Michel

Private Sub CommandButton1_Click()
If CheckBox1 Then
ActiveCell.Value = "alpha"
End If
If CheckBox2 Then
ActiveCell.Value = "bêta"
End If
If CheckBox3 Then
ActiveCell.Value = "charly"
End If
If CheckBox4 Then
ActiveCell.Value = "echo"
End If
End Sub


Bonsoir,

Non testé :

Private Sub CommandButton1_Click()
txt = ""
If CheckBox1 Then
txt = txt & "@alpha"
End If
If CheckBox2 Then
txt = txt & "@bêta"
End If
If CheckBox3 Then
txt = txt &"@charly"
End If
If CheckBox4 Then
txt = txt & "@echo"
End If
if left(txt,1)="@" then txt = right(txt,len(txt)-1)
txt = replace(txt , "@" , " + ")
activecell.value = txt
End Sub

@+
FxM

Avatar
verificator
bonsoir Michel,

Private Sub CommandButton1_Click()
ActiveCell = ""
MonTableau = Array("alpha", "bêta", "charly", "echo")

For i = 0 To Me.Controls.Count - 1
If TypeName(Controls(i)) = "CheckBox" And Controls(i)
= True Then
ActiveCell = ActiveCell & " " & MonTableau(i)
End If
Next

End Sub

amicalement

-----Original Message-----
Bonjour à toutes et tous
J'ai un userform avec ce code :
Je souhaite que si l'utilisateur coche par exemple le
checkbox1 et le 3

dans la cellule active, il y a : alpha + charly
merci et bonne soirée
Michel

Private Sub CommandButton1_Click()
If CheckBox1 Then
ActiveCell.Value = "alpha"
End If
If CheckBox2 Then
ActiveCell.Value = "bêta"
End If
If CheckBox3 Then
ActiveCell.Value = "charly"
End If
If CheckBox4 Then
ActiveCell.Value = "echo"
End If
End Sub



.



Avatar
verificator
Michel,

damned, j'ai oublié le "+"
----------------------------------------------------
Private Sub CommandButton1_Click()
ActiveCell = ""
MonTableau = Array("alpha", "bêta", "charly", "echo")

For i = 0 To Me.Controls.Count - 1
If TypeName(Controls(i)) = "CheckBox" And Controls(i)
= True Then
ActiveCell = ActiveCell & MonTableau(i) & " + "
End If
Next
If Len(ActiveCell) > 0 Then
ActiveCell = Mid(ActiveCell, 1, Len(ActiveCell) - 2)
End If
End Sub
----------------------------------------------------

je corrige because FXM est déjà rentré au port

amicalement


-----Original Message-----
bonsoir Michel,

Private Sub CommandButton1_Click()
ActiveCell = ""
MonTableau = Array("alpha", "bêta", "charly", "echo")

For i = 0 To Me.Controls.Count - 1
If TypeName(Controls(i)) = "CheckBox" And Controls
(i)

= True Then
ActiveCell = ActiveCell & " " & MonTableau(i)
End If
Next

End Sub

amicalement

-----Original Message-----
Bonjour à toutes et tous
J'ai un userform avec ce code :
Je souhaite que si l'utilisateur coche par exemple le
checkbox1 et le 3

dans la cellule active, il y a : alpha + charly
merci et bonne soirée
Michel

Private Sub CommandButton1_Click()
If CheckBox1 Then
ActiveCell.Value = "alpha"
End If
If CheckBox2 Then
ActiveCell.Value = "bêta"
End If
If CheckBox3 Then
ActiveCell.Value = "charly"
End If
If CheckBox4 Then
ActiveCell.Value = "echo"
End If
End Sub



.

.





Avatar
FxM
au port, au port, vite dit ... 'suis pas Marseillais, moi :o)

@+
FxM



Michel,

damned, j'ai oublié le "+"
----------------------------------------------------
Private Sub CommandButton1_Click()
ActiveCell = ""
MonTableau = Array("alpha", "bêta", "charly", "echo")

For i = 0 To Me.Controls.Count - 1
If TypeName(Controls(i)) = "CheckBox" And Controls(i)
= True Then
ActiveCell = ActiveCell & MonTableau(i) & " + "
End If
Next
If Len(ActiveCell) > 0 Then
ActiveCell = Mid(ActiveCell, 1, Len(ActiveCell) - 2)
End If
End Sub
----------------------------------------------------

je corrige because FXM est déjà rentré au port

amicalement


Avatar
Michel
Merci à tous les deux impecc !
Michel

"FxM" a écrit dans le message de news:

au port, au port, vite dit ... 'suis pas Marseillais, moi :o)

@+
FxM



Michel,

damned, j'ai oublié le "+"
----------------------------------------------------
Private Sub CommandButton1_Click()
ActiveCell = ""
MonTableau = Array("alpha", "bêta", "charly", "echo")

For i = 0 To Me.Controls.Count - 1
If TypeName(Controls(i)) = "CheckBox" And Controls(i) = True Then
ActiveCell = ActiveCell & MonTableau(i) & " + "
End If
Next
If Len(ActiveCell) > 0 Then
ActiveCell = Mid(ActiveCell, 1, Len(ActiveCell) - 2)
End If
End Sub
----------------------------------------------------

je corrige because FXM est déjà rentré au port

amicalement