Bonjour à tous,
J'ai écris une macro qui popule le contenu d'une base de données dans des tableaux. A la base ce travail devait être fait pour une dizaine de tableaux seulement, qui s'est maintenant transformés en plus de...600.
Voici la macro
Sub FillwithCMrules()
Dim LastRow As Double
Dim Lastcol As Double
Set ws1 = ActiveWorkbook.Worksheets("Database")
Set ws2 = ActiveWorkbook.Worksheets("Tabletofill")
LastRow = ws1.Cells(ws1.Rows.Count, 1).End(xlUp).Row
Lastcol = ws1.Cells(1, ws1.Columns.Count).End(xlToLeft).Column
For i = 1 To Lastcol
If Cells(1, i) = "Concatenate" Then
c1 = i
ElseIf Cells(1, i) = "CMrules" Then
c2 = i
End If
Next
For r = 2 To LastRow
'find the text from the database
textFind = ws1.Cells(r, c1)
'find the text to replace from the database
TextReplace = ws1.Cells(r, c2)
Set cell = ws2.Cells.Find(What:=textFind)
If Not cell Is Nothing Then
cell.Value = TextReplace
End If
Next
End Sub
Ma question est la suivante, est-ce possible d'appliquer ce code à une sélection de feuilles dans le workbook? J'ai pensé à modifier cette ligne : Set ws2 = ActiveWorkbook.Worksheets("Tabletofill") mais je n'ai pas d'idée sur comment cela pourrait fonctionner.
Des idées?
Merci à tous.