Microsoft 365 ComboBox : Est-il possible d'agrandir l'affichage ?

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,
Je vous souhaite une belle journée :)

Je me tourne une nouvelle fois vers nos ténors car je n'arrive pas à grossir l'affichage de ma ComboBox,
Est-ce possible ? :
1649659509288.png

VB:
Sub Laurent()
    Dim WS As Worksheet
    Set WS = ActiveSheet
    Dim tbl() As Variant
    tbl = Array("Metropole 33", "988 Nouvelle-Calédonie  687", "987 Polynésie française 689", _
    "974 La Réunion  262", "973 Guyane 594", "972 Martinique 596", "971 Guadeloupe 590", 0) '"",

    ' Les valeurs
    ReDim Preserve tbl(UBound(tbl) - 1)
    ' La Liste Box
    Dim oCombo As OLEObject
    Dim L As Single, H As Single, T As Single, W As Single
    L = ActiveCell.Offset(, 1).Left   '<-- position horizontale
    T = ActiveCell.Top  '<-- position verticale
    W = 202 '<-- largeur
    H = 15 '<-- hauteur
    ' Si la liste existe
    For Each oCombo In WS.OLEObjects
        If oCombo.progID = "Forms.ComboBox.1" Then
            If oCombo.Name = "Combo1" Then
                oCombo.Delete
            End If
        End If
    Next
    ' Creation de la liste de choix
    Set oCombo = WS.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Left:=L, Top:=T, Width:=W, Height:=H)
    With oCombo
    .Name = "Combo1" '<-- nom du Combobox
    .Object.List() = tbl '<-- exemple de chargement des données
    .Activate
    .Object.DropDown
    End With
    Set oCombo = Nothing
End Sub
Je joins un fichier test et je continue mes recherches.
Je vous remercie pour votre aide,
Amicalement,
lionel :)
 

Pièces jointes

  • inputBox_affichage.xlsm
    52.9 KB · Affichages: 8
Dernière édition:
Solution
Comme ça, là, déjà ce serait beaucoup plus simple, non ? :
VB:
Option Explicit
Private Sub Worksheet_Activate()
   [A1].Select
   End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Not Application.Intersect(Target, Range("F6:F15")) Is Nothing Then
      Cancel = True
      With Me.Combo1
         .List = Array("Metropole 33", "988 Nouvelle-Calédonie  687", "987 Polynésie française 689", _
            "974 La Réunion  262", "973 Guyane 594", "972 Martinique 596", "971 Guadeloupe 590")
         .Left = Target.Offset(, 1).Left   '<-- position horizontale
         .Top = Target.Top '<-- position verticale
         .Width = 202 '<-- largeur
         .Height = Target.Height '<-- hauteur...

Dranreb

XLDnaute Barbatruc
Comme ça, là, déjà ce serait beaucoup plus simple, non ? :
VB:
Option Explicit
Private Sub Worksheet_Activate()
   [A1].Select
   End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Not Application.Intersect(Target, Range("F6:F15")) Is Nothing Then
      Cancel = True
      With Me.Combo1
         .List = Array("Metropole 33", "988 Nouvelle-Calédonie  687", "987 Polynésie française 689", _
            "974 La Réunion  262", "973 Guyane 594", "972 Martinique 596", "971 Guadeloupe 590")
         .Left = Target.Offset(, 1).Left   '<-- position horizontale
         .Top = Target.Top '<-- position verticale
         .Width = 202 '<-- largeur
         .Height = Target.Height '<-- hauteur
         .Visible = True
         .DropDown
         End With
      End If
   End Sub
Private Sub Combo1_Change()
   If Combo1.MatchFound Then
      Combo1.Visible = False
      ActiveCell.Value = Left$(Combo1.Text, 3) & Right$(ActiveCell.Value, 9)
      Combo1.Text = ""
      [A1].Select
      End If
   End Sub
 
Dernière édition:

ChTi160

XLDnaute Barbatruc
Re
une autre vidéo !
avec mise a jour du numéro !
VB:
Private Sub Worksheet_Activate()
Cancel = False
[a1].Select
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Application.Intersect(Target, Range("f6:f15")) Is Nothing Then
Cancel = True
Laurent
End If
End Sub

Private Sub Combo1_Change()
    Dim WS As Worksheet
    Dim Indic As String
    Set WS = ActiveSheet
    
    Set oCombo = ActiveSheet.OLEObjects("Combo1")
         Indic = Right(oCombo.Object.Text, 3) & Right(ActiveCell, 9)
                ActiveCell.Value = Indic
                  oCombo.Visible = False
 Set oCombo = Nothing
[a1].Select
End Sub
Sub Laurent()
   Dim tbl() As Variant
    ' Les valeurs
    Dim L As Single, H As Single, T As Single, W As Single
   Set oCombo = ActiveSheet.OLEObjects("Combo1")
  
    tbl = Array("Metropole 33", "988 Nouvelle-Calédonie  687", "987 Polynésie française 689", _
    "974 La Réunion  262", "973 Guyane 594", "972 Martinique 596", "971 Guadeloupe 590") '"",
  
    L = ActiveCell.Offset(, 1).Left   '<-- position horizontale
    T = ActiveCell.Top  '<-- position verticale
    W = 302 '<-- largeur
    H = 1 '<-- hauteur
    With oCombo
         .Visible = True
         .Left = L
         .Top = T
         .Width = W
         .Height = H
         .Object.Font.Name = "Calibri"
         .Object.FontSize = 24
         .Object.List() = tbl '<-- exemple de chargement des données
         .Activate
         .Object.DropDown
    End With
    Set oCombo = Nothing
End Sub
Jean marie
 

Pièces jointes

  • Lionel-2.gif
    Lionel-2.gif
    686.4 KB · Affichages: 21

Discussions similaires

H
Réponses
19
Affichages
5 K

Statistiques des forums

Discussions
312 033
Messages
2 084 800
Membres
102 672
dernier inscrit
gemo911