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 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Option Explicit
Dim tabComboBoxesWIP As Variant
Dim tabTMP As Variant
Sub fillDestinationsInitialize(fileToLookInto As String, comboBoxToFill As Control, nColPlage As Integer, nbRowBeginning As Integer)
' charge la liste de choix a l'entree dans le champ
Dim i As Integer
Dim j As Integer
Dim maxTabSRows As Integer
Dim comboBoxValueTmp As String
Dim Wk As Workbook
Dim Ws As Worksheet
Dim tokenAlreadyIn As Boolean
i = j = maxTabSRows = 0
tokenAlreadyIn = False
comboBoxToFill.Clear
Set Wk = Workbooks.Open(fileName:=fileToLookInto)
maxTabSRows = ActiveSheet.UsedRange.Rows.Count
Set plage = ActiveSheet.Range(Cells(1 + nbRowBeginning, nColPlage), Cells(maxTabSRows, nColPlage))
tabComboBoxesWIP = plage
ActiveWorkbook.Close
ReDim tabTMP(1)
For i = LBound(tabComboBoxesWIP) To UBound(tabComboBoxesWIP)
For j = LBound(tabTMP) To UBound(tabTMP)
If tabTMP(j) <> tabComboBoxesWIP(i) Then
ReDim Preserve tabTMP(UBound(tabTMP) + 1)
tabTMP(UBound(tabTMP)) = tabComboBoxesWIP(i)
Else
Exit For
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub |
Partager