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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Option Explicit
Sub test()
Dim F1 As Worksheet
Dim F2 As Worksheet
Set F1 = Sheets("Labelling")
Set F2 = Sheets("Impression AutoCad")
Dim i As Long
Dim j As Long
Dim Ligne As Long
Dim plage1 As Range
Dim c As Range
Dim plage2 As Range
Dim plage3 As Range
Dim plage4 As Range
Application.ScreenUpdating = False
F2.Columns("A:B").ClearContents
With F1
Set plage1 = .Range("B5:B134")
Set plage2 = .Range("D5:D134")
Set plage3 = .Range("F5:F134")
Set plage4 = .Range("H5:H134")
End With
Ligne = 1
For Each c In plage1
If c.Value <> 0 And c.Value <> "" Then
F2.Cells(Ligne, 1) = F1.Cells(c.Row, 1)
F2.Cells(Ligne, 2) = c.Value
F2.Cells(Ligne, 1).Interior.Color = F1.Cells(c.Row, 1).Interior.Color
F2.Cells(Ligne, 2).Interior.Color = c.Interior.Color
End If
If F2.Cells(Ligne, 1) <> "" Then Ligne = Ligne + 1
Next c
For Each c In plage2
If c.Value <> 0 And c.Value <> "" Then
F2.Cells(Ligne, 1) = F1.Cells(c.Row, 3)
F2.Cells(Ligne, 2) = c.Value
F2.Cells(Ligne, 1).Interior.Color = F1.Cells(c.Row, 3).Interior.Color
F2.Cells(Ligne, 2).Interior.Color = c.Interior.Color
End If
If F2.Cells(Ligne, 1) <> "" Then Ligne = Ligne + 1
Next c
For Each c In plage3
If c.Value <> 0 And c.Value <> "" Then
F2.Cells(Ligne, 1) = F1.Cells(c.Row, 5)
F2.Cells(Ligne, 2) = c.Value
F2.Cells(Ligne, 1).Interior.Color = F1.Cells(c.Row, 5).Interior.Color
F2.Cells(Ligne, 2).Interior.Color = c.Interior.Color
End If
If F2.Cells(Ligne, 1) <> "" Then Ligne = Ligne + 1
Next c
For Each c In plage4
If c.Value <> 0 And c.Value <> "" Then
F2.Cells(Ligne, 1) = F1.Cells(c.Row, 7)
F2.Cells(Ligne, 2) = c.Value
F2.Cells(Ligne, 1).Interior.Color = F1.Cells(c.Row, 7).Interior.Color
F2.Cells(Ligne, 2).Interior.Color = c.Interior.Color
End If
If F2.Cells(Ligne, 1) <> "" Then Ligne = Ligne + 1
Next c
F2.Select
Application.ScreenUpdating = True
End Sub |
Partager