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
| Sub correction_nom()
Dim line As Integer
Dim col As Integer
Dim last_line As Integer
Dim last_col As Integer
Dim val As String
Dim oldVal As String
Dim NewVal As String
line = 2: col = 1
'Worksheets("Renommer").Activate
last_line = Sheets("renommer").Cells.SpecialCells(xlCellTypeLastCell).Row
'last_line = Sheets("renommer").Range("B2", Range("B2").End(xlDown)).Count
last_col = Sheets("renommer").Cells.SpecialCells(xlCellTypeLastCell).Column
For line = 2 To last_line
oldVal = Sheets("Renommer").Cells(line, 1).Value
NewVal = Sheets("Renommer").Cells(line, 2).Value
FindMyValue oldVal, NewVal
' RemplacerChaine ActiveSheet.UsedRange, oldVal, NewVal
Next line
MsgBox "Traitement terminé !!"
End Sub
Sub FindMyValue(oldV, NewV)
Dim c As Range
Dim firstAddress As String
With Worksheets(1).Range("B2", Range("B2").End(xlDown))
Set c = .Find(oldV, LookIn:=xlValues, SearchOrder:=xlByColumns, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
' c.Value = c.Value.ToString
c.Value = Replace(c.Value, oldV, NewV, , , vbTextCompare)
Set c = .FindNext(c)
Loop While c.Address <> firstAddress
End If
End With
End Sub |