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
| Private Sub CommandButton1_Click()
Dim cell, cell1, cell2, plage1, plage2 As Range
Dim num_recherche, indice_ligne As Integer
Dim w1,w2 As Worksheet
Set w1 = ActiveWorkbook.Worksheets("EXPERTISE (Ecriture)")
Set w2 = ActiveWorkbook.Worksheets("Tableau")
num_recherche = w1.Cells(2, 21).Value
For Each cell In w2.Range("A4:A500")
If cell.Value = num_recherche Then
indice_ligne = cell.Value
End If
Next cell
Set plage1 = Union(w1.Cells(5, 3), w1.Cells(5, 11), w1.Cells(5, 17))
Set plage2 = Union(w2.Cells(indice_ligne, 8), w2.Cells(indice_ligne, 4), w2.Cells(indice_ligne, 38))
For Each cell1 In plage1
MsgBox (cell1.Value)
If cell1.Value <> "" Then
For Each cell2 In plage2
MsgBox (cell2.Value)
cell1.Copy
cell2.PasteSpecial Paste:=xlPasteValues
'Idem avec :cell2.Value=cell1.Value
MsgBox (cell2.Value)
Next cell2
End If
Next cell1
MsgBox ("Fin")
End Sub |
Partager