Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2016 Application.Intersect

dede869

XLDnaute Occasionnel
Bonjour a vous, j'ai trouver cette formule,

Application.Intersect(Range("Test"), Range("Sample")).Select

Est il possible que le range ("Test") peut etre changer par la sélection que je fait dans un combobox1 et la mème chose pour l'autre par combobox2 .

Merci
 

Dranreb

XLDnaute Barbatruc
Bonsoir.
Je verrais bien un code à peu près comme ça :
VB:
Option Explicit
Private PlgDon As Range, PlgSel As Range, TSel(), L&

Private Sub UserForm_Initialize()
Set PlgDon = Feuil2.[D3:M134]
End Sub

Private Sub ListBox1_Click()
If ListBox2.ListIndex = -1 Then Exit Sub
ListBox2_Click
End Sub

Private Sub ListBox2_Click()
If ListBox1.ListIndex = -1 Then Exit Sub
Set PlgSel = PlgDon.Offset(11 * ListBox1.ListIndex, ListBox2.ListIndex).Resize(11, 1)
TSel = PlgSel.Value
For L = 1 To 11: Me("Textbox" & L + 11).Text = TSel(L, 1): Next L
End Sub

Private Sub CommandButton3_Click()
On Error Resume Next
For L = 1 To 11
   Err.Clear: TSel(L, 1) = CCur(Me("Textbox" & L + 11).Text)
   If Err Then TSel(L, 1) = Empty
   Next L
PlgSel.Value = TSel
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub
 
Dernière édition:

Dranreb

XLDnaute Barbatruc
Bonsoir.
Le plus simple serait de renoncer à la boucle en sortie. CCur convertit en Currency, CDbl en Double.
Sinon un Select Case C: Case 12 To 15, 17, 20 To 22 pourrait permettre de la conserver.
 
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…