Salut,
Je ne sais pas si j'ai tout compris mais bon je tente
c'est d’insérer le caption dans un commentaire qui est déjà rempli (j'y arrive mais cela m'efface tout le commentaire et me rajoute "le caption"
petite fonction...
Function SetComment(ByRef TheRange As Range)
Dim Ctrl As Control
Dim strTemp As String
strTemp = "Fast :" & Chr(10) & "Type : " & Chr(10) & "Bass :" & Chr(10) & "" & Chr(10) & ""
With Me
For Each Ctrl In .Controls
If TypeName(Ctrl) = "OptionButton" And Ctrl.Value = True Then
strTemp = Replace(strTemp, .TextBox16 & " : ", .TextBox16 & " : " & Ctrl.Caption)
End If
Next
TheRange.Comment.Text Text:=strTemp
End With
End Function
et pour l'appel tu fais
Private Sub Valider_Click()
SetComment Range("L8")
Unload Me
End Sub
Pour rendre universelle la Fonction SetComment, je conseille de renommer les TextBox de tes UserForm en TextBox1 et de changer ce nom dans la fonction. Tu pourrais aussi remplacer le textBox par un ComboBox et attribuer un Array pour sa propriété list.
La fonction RemetComment peut aussi être généralisée avec une variable optionnelle.
' // RemetComment By Jean-Paul (Valtrase) le : 08/04/2022
' // Réinitialise un commentaire de cellule, si TheRange n'est pas défini c'est L8 qui est pris par défaut
Sub RemetComment(Optional ByRef TheRange As Range)
Application.ScreenUpdating = False
If TheRange Is Nothing Then Set TheRange = Range("A1").Offset(0, 11)
With TheRange
.Comment.Text Text:="Fast :" & Chr(10) & "Type : " & Chr(10) & "Bass : "
.Comment.Shape.Height = 50
End With
Application.ScreenUpdating = True
End Sub
Voilà, en attente d'un retour.