Bonjour à tous,

J'ai un code qui marche avec Sheets().select , mais j'aimerai éviter le .select car cela me ramène sur la feuille selectionnée. J'ai essayé avec with mas ça ne marche pas. Voici le code avec select :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
Sheets("Consommation").Select
 
LigneA = Range("A" & Rows.Count).End(xlUp).Row
LigneB = Range("B" & Rows.Count).End(xlUp).Row
 
ComboBox1.RowSource = "A5:A" & LigneA - 2
ComboBox2.RowSource = "B5:B" & LigneB - 2
Et voici ce que j'ai essayé avec with :

With Sheets("Consommation")

LigneA = .Range("A" & .Rows.Count).End(xlUp).Row
LigneB = .Range("B" & .Rows.Count).End(xlUp).Row

ComboBox1.RowSource = "A5:A" & LigneA - 2
ComboBox2.RowSource = "B5:B" & LigneB - 2

End With
Est ce que quelqu'un pourrait m'aider? Merci