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 43 44 45 46 47 48 49 50 51
| Sub TraitementNomenclature()
'les variables
Dim Article As String
Dim NumRows As Integer
Dim NbCells As Integer
Dim j, x As Integer
' les objets
Dim Cellule As Range
Dim wshO As Excel.Worksheet
Dim wshD As Excel.Worksheet
' instantiation
Set wshO = Application.ThisWorkbook.Worksheets("Part")
Set wshD = Application.ThisWorkbook.Worksheets("Feuil1")
With wshD
NbCells = Application.WorksheetFunction.CountA(Feuil1.Range("$A:$A"))
For i = 1 To NbCells
If Left(Cells(i, 1), 2) = "18" Or Left(Cells(i, 1), 2) = "19" Then
Article = Cells(i, 1)
'Niveau
Cells(i, 13) = "0"
wshO.Activate
NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
For j = 1 To NumRows
If Cells(j, 1) = Article Then
'copier cellule E,F,G de la feuille "Part" vers les cellules J,K,L de la feuille "Feuil1"
With wshO
'cette ligne marche correctement
'wshD.Range(wshD.Cells(i, 10), wshD.Cells(i, 11)).Value = .Range(.Cells(j, 5), .Cells(j, 6)).Value
' celle-ci génère une erreur : nombre d'arguments incorrect ou affectation des propriétés incorrecte !
wshD.Range(wshD.Cells(i, 10), wshD.Cells(i, 11), wshD.Cells(i, 12)).Value = .Range(.Cells(j, 5), .Cells(j, 6), .Cells(j, 7)).Value
End With
End If
Next
End If
If i <> 1 Then
'UNIT_OF_MEASURE: default "EA"
Cells(i, 14) = "EA"
End If
Next
End With
End Sub |
Partager