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
| Option Base 1
Sub charger()
Dim extraitfeuille()
colonneactive = Array("souscripteur", "prix", "actif", "type de placement")
nblignes = ActiveSheet.UsedRange.Rows.Count
dernierecolonne = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
feuilleactive = Range(Cells(1, 1), Cells(nblignes, dernierecolonne))
ReDim extraitfeuille(nblignes, UBound(colonneactive))
For colonne = LBound(colonneactive) To UBound(colonneactive)
extraitfeuille(1, colonne) = colonneactive(colonne)
With ActiveSheet.Range(Cells(1, 1), Cells(1, dernierecolonne))
Set c = .Find(colonneactive(colonne), LookIn:=xlValues)
If Not c Is Nothing Then
colonnedansfeuille = c.Column
For ligne = 2 To nblignes
extraitfeuille(ligne, colonne) = feuilleactive(ligne, colonnedansfeuille)
Next
End If
End With
Next
ActiveSheet.Range(Cells(1, 1), Cells(nblignes, dernierecolonne)).ClearContents
ActiveSheet.Range(Cells(1, 1), Cells(nblignes, 4)) = extraitfeuille
End Sub |
Partager