Bonjour à tous,
J'arrive à alimenter ma ComboBox :
- par ordre alphabétique
- si "PFMP 4 S1" Range("D4: D39") > 0
J'aimerais savoir si je peux rajouter l'option si "Synthèse" Range("F5:F40") <> ""
Pour résumer, si ma cellule dans cette plage est vide, na pas ajouter la ligne associer dataRange (otherSheet.Range("A4:A39")).
Je suis décalé d'une ligne entre mes deux feuilles...
Sur la feuille synthèse je vais de la ligne 5 à 40 et sur la ligne synthèse je vais de la ligne 4 à 39.
Voici mon code :
Merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Private Sub ComboBoxAffectation_GotFocus() Dim ws As Worksheet, otherSheet As Worksheet Dim checkRange As Range, dataRange As Range, cell As Range, checkCell As Range Dim tempArray() As String Dim cellCount As Long Set ws = ThisWorkbook.Sheets("Synthèse") Set otherSheet = ThisWorkbook.Sheets("PFMP 4 S1") Set checkRange = otherSheet.Range("D4:D39") Set dataRange = otherSheet.Range("A4:A39") cellCount = 0 ReDim tempArray(1 To dataRange.Count) For Each cell In dataRange Set checkCell = checkRange.Cells(cell.Row - 3, 1) If Len(cell.Value) > 0 And checkCell.Value > 0 Then cellCount = cellCount + 1 tempArray(cellCount) = cell.Value End If Next cell If cellCount > 0 Then ReDim Preserve tempArray(1 To cellCount) Call BubbleSort(tempArray) Me.ComboBoxAffectation.List = tempArray End If End Sub
Partager