Cette macro ne fonctionne pas tout a fait. Pourquoi ?
Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis
bug a la fonction
If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Click()
Dim i&
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.Selected(i) = True Then '
Range("P2").Value = ComboBox1.List(i)
Exit For
End If
Next i
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
michdenis
Bonsoir David,
Le problème avec cette procédure, c'est qu'elle est écrite comme si ton contrôle était une "ListBox" au lieu d'un "Combobox". La méthode "Selected(i) est utilisable lorsque tu as une "listbox" dont la propriété :" Multiselect" a été défini à : "fmMultiselectMulti"
'------------------------------------- Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub '-------------------------------------
Remplace la procédure précédente par :
'----------------------- Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If
End Sub '-----------------------
Salutations!
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news: Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ? Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis bug a la fonction If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub
Merci à tous de votre aide très précieuse David
-- direction-ternoise@(supprimerceci)wanadoo.fr
Bonsoir David,
Le problème avec cette procédure, c'est qu'elle est écrite comme si ton contrôle était une "ListBox" au lieu d'un
"Combobox". La méthode "Selected(i) est utilisable lorsque tu as une "listbox" dont la propriété :" Multiselect" a été
défini à : "fmMultiselectMulti"
'-------------------------------------
Private Sub ComboBox1_Click()
Dim i&
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.Selected(i) = True Then '
Range("P2").Value = ComboBox1.List(i)
Exit For
End If
Next i
End Sub
'-------------------------------------
Remplace la procédure précédente par :
'-----------------------
Private Sub ComboBox1_Click()
Dim i&
If ComboBox1.Text <> "" Then
Range("P2").Value = ComboBox1.List(i)
End If
End Sub
'-----------------------
Salutations!
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de
news:u3hsIYo9DHA.2316@TK2MSFTNGP11.phx.gbl...
Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ?
Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis
bug a la fonction
If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Click()
Dim i&
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.Selected(i) = True Then '
Range("P2").Value = ComboBox1.List(i)
Exit For
End If
Next i
End Sub
Le problème avec cette procédure, c'est qu'elle est écrite comme si ton contrôle était une "ListBox" au lieu d'un "Combobox". La méthode "Selected(i) est utilisable lorsque tu as une "listbox" dont la propriété :" Multiselect" a été défini à : "fmMultiselectMulti"
'------------------------------------- Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub '-------------------------------------
Remplace la procédure précédente par :
'----------------------- Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If
End Sub '-----------------------
Salutations!
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news: Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ? Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis bug a la fonction If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub
Merci à tous de votre aide très précieuse David
-- direction-ternoise@(supprimerceci)wanadoo.fr
David T.
Bonjour denis
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas. Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc dans cette liste Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ListBox1.Clear ListBox1.List = Arr End Sub
Private Sub ListBox1_Click() Dim i& If ListBox1.Text <> "" Then Range("P2").Value = ListBox1.List(i) End If End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If End Sub
Bonjour denis
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas.
Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc
dans cette liste
Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ListBox1.Clear
ListBox1.List = Arr
End Sub
Private Sub ListBox1_Click()
Dim i&
If ListBox1.Text <> "" Then
Range("P2").Value = ListBox1.List(i)
End If
End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Click()
Dim i&
If ComboBox1.Text <> "" Then
Range("P2").Value = ComboBox1.List(i)
End If
End Sub
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas. Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc dans cette liste Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ListBox1.Clear ListBox1.List = Arr End Sub
Private Sub ListBox1_Click() Dim i& If ListBox1.Text <> "" Then Range("P2").Value = ListBox1.List(i) End If End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If End Sub
Alain CROS
Bonjour.
N'aurais tu pas des feuilles Boite de dialogue XL5 ? Remplace Sheets par WorkSheets.
Alain CROS.
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news:
Bonjour denis
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas. Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc dans cette liste Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ListBox1.Clear ListBox1.List = Arr End Sub
Private Sub ListBox1_Click() Dim i& If ListBox1.Text <> "" Then Range("P2").Value = ListBox1.List(i) End If End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If End Sub
Bonjour.
N'aurais tu pas des feuilles Boite de dialogue XL5 ?
Remplace Sheets par WorkSheets.
Alain CROS.
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news: O25j9Ds9DHA.2644@TK2MSFTNGP11.phx.gbl...
Bonjour denis
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas.
Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc
dans cette liste
Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ListBox1.Clear
ListBox1.List = Arr
End Sub
Private Sub ListBox1_Click()
Dim i&
If ListBox1.Text <> "" Then
Range("P2").Value = ListBox1.List(i)
End If
End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Click()
Dim i&
If ComboBox1.Text <> "" Then
Range("P2").Value = ComboBox1.List(i)
End If
End Sub
N'aurais tu pas des feuilles Boite de dialogue XL5 ? Remplace Sheets par WorkSheets.
Alain CROS.
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news:
Bonjour denis
Merci de ta réponse, cela ne bug plus mais ne fonctionne toujours pas. Cela innitialise bien la liste mais en plus mais des dialogue1,dialogue2,etc dans cette liste Que ce soit aussi bien avec un ListBox avec :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ListBox1.Clear ListBox1.List = Arr End Sub
Private Sub ListBox1_Click() Dim i& If ListBox1.Text <> "" Then Range("P2").Value = ListBox1.List(i) End If End Sub
OU avec un ComboBox :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& If ComboBox1.Text <> "" Then Range("P2").Value = ComboBox1.List(i) End If End Sub
Michel Pierron
Bonjour David; Pourquoi n'est-ce pas tout simplement: Private Sub ComboBox1_Click() If ComboBox1.ListIndex = -1 Then Exit Sub Range("P2") = ComboBox1.Value End Sub
MP
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news:
Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ? Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis bug a la fonction If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub
Merci à tous de votre aide très précieuse David
-- direction-ternoise@(supprimerceci)wanadoo.fr
Bonjour David;
Pourquoi n'est-ce pas tout simplement:
Private Sub ComboBox1_Click()
If ComboBox1.ListIndex = -1 Then Exit Sub
Range("P2") = ComboBox1.Value
End Sub
MP
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message
de news:u3hsIYo9DHA.2316@TK2MSFTNGP11.phx.gbl...
Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ?
Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis
bug a la fonction
If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(1 To Sheets.Count)
For i = 1 To Sheets.Count
Arr(i) = Sheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Click()
Dim i&
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.Selected(i) = True Then '
Range("P2").Value = ComboBox1.List(i)
Exit For
End If
Next i
End Sub
Bonjour David; Pourquoi n'est-ce pas tout simplement: Private Sub ComboBox1_Click() If ComboBox1.ListIndex = -1 Then Exit Sub Range("P2") = ComboBox1.Value End Sub
MP
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news:
Bonsoir à tous
Cette macro ne fonctionne pas tout a fait. Pourquoi ? Cela m'affiche bien le nom des onglets + des Dialogue1, Dialogue2, etc puis bug a la fonction If ComboBox1.Selected(i) = True Then '
Précision : le ComboBox1 se trouve sur une feuille pas dans un UserForm.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(1 To Sheets.Count) For i = 1 To Sheets.Count Arr(i) = Sheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Click() Dim i& For i = 0 To ComboBox1.ListCount - 1 If ComboBox1.Selected(i) = True Then ' Range("P2").Value = ComboBox1.List(i) Exit For End If Next i End Sub
Cela fonctionne aussi avec cette Proc, merci A titre d'information, quelle est la différence si le résultat est le meme ?
Merci pour l'explication
Salutations David
David T.
Un petit truc qui dérange quand meme !!!
Le ComboBox1 ne s'affiche pas toujours. Il faut que le clic sur la feuille pour qu'il apparaise puis je sélectionne et je dois refaire un clic dans le ComboBox. Pas facile !!!
Es qu'il est possible qu'il reste toujours disponible. Je sélectionne et ca referme la selection ?
Merci de votre aide
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(4 To Worksheets.Count) For i = 4 To Worksheets.Count Arr(i) = Worksheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Change() If ComboBox1.ListIndex = -1 Then Exit Sub Range("P2") = ComboBox1.Value End Sub
Un petit truc qui dérange quand meme !!!
Le ComboBox1 ne s'affiche pas toujours. Il faut que le clic sur la feuille
pour qu'il apparaise puis
je sélectionne et je dois refaire un clic dans le ComboBox. Pas facile !!!
Es qu'il est possible qu'il reste toujours disponible. Je sélectionne et ca
referme la selection ?
Merci de votre aide
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Arr, i
ReDim Arr(4 To Worksheets.Count)
For i = 4 To Worksheets.Count
Arr(i) = Worksheets(i).Name
Next
ComboBox1.Clear
ComboBox1.List = Arr
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then Exit Sub
Range("P2") = ComboBox1.Value
End Sub
Le ComboBox1 ne s'affiche pas toujours. Il faut que le clic sur la feuille pour qu'il apparaise puis je sélectionne et je dois refaire un clic dans le ComboBox. Pas facile !!!
Es qu'il est possible qu'il reste toujours disponible. Je sélectionne et ca referme la selection ?
Merci de votre aide
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Arr, i ReDim Arr(4 To Worksheets.Count) For i = 4 To Worksheets.Count Arr(i) = Worksheets(i).Name Next ComboBox1.Clear ComboBox1.List = Arr End Sub
Private Sub ComboBox1_Change() If ComboBox1.ListIndex = -1 Then Exit Sub Range("P2") = ComboBox1.Value End Sub
Michel Pierron
Evident David; c'est beauoup plus simple. MP
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message de news:Oeqc%
Bonjour et merci Michel
Cela fonctionne aussi avec cette Proc, merci A titre d'information, quelle est la différence si le résultat est le meme ?
Merci pour l'explication
Salutations David
Evident David; c'est beauoup plus simple.
MP
"David T." <direction-ternoise@(supprimerceci)wanadoo.fr> a écrit dans le message
de news:Oeqc%23Hu9DHA.2028@TK2MSFTNGP10.phx.gbl...
Bonjour et merci Michel
Cela fonctionne aussi avec cette Proc, merci
A titre d'information, quelle est la différence si le résultat est le meme ?