Re : Gestion des interventions et stock
Bonjour;
comme d'habitude après plusieurs jours de recherche j'ai réussi à le faire mais j'ai toujours un problème de compilation quelqu'un pourra m'aider SVP je n'arrive pas a trouver l'erruer.
Sub Uniques()
Sheets("StockMagasin").Select
Range("B7:Q410").Select
ActiveWorkbook.Worksheets("StockMagasin").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("StockMagasin").Sort.SortFields.Add Key:=Range("B8:B410" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("StockMagasin").Sort
.SetRange Range("B7:N410")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim Magasin As Variant
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim i As Integer, j As Integer, x As Integer, y As Integer, z As Integer
Dim Swap1, Swap2, Item
Dim der1 As Long
Dim der2 As Long
der1 = Sheets("StockMagasin").Cells(Application.Rows.Count, "B").End(xlUp).Row
der2 = Sheets("Listes").Cells(Application.Rows.Count, "Q").End(xlUp).Row
Sheets("Listes").Range("B8:Q" & der2).ClearContents
Set AllCells = Sheets("StockMagasin").Range("B8:B" & der1)
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
Next Cell
On Error GoTo 0
Magasin = Sheets("StockMagasin").Range("B8:C1000").Value
i = 2
j = 1
For Each Item In NoDupes
Sheets("Listes").Cells(i, j).Value = Item
y = j
For x = 1 To UBound(Magasin)
If Magasin(x, 1) = Item Then
Sheets("Listes").Cells(x + 2 - z, y).Value = Magasin(x, 2)
End If
Next x
j = j + 1
z = Sheets("Listes").Range(Cells(i + 1, 1), Cells(1000, j - 1)).Cells.SpecialCells(xlCellTypeConstants).Count
Next Item
End Sub