Bonjour,
Un début de réponse pour débuter.
Cdlt.
Option Explicit
'Convert_Reference Type Macro
'A Visual Basic module to convert absolute references to relative
'references or relative references to absolute references.
Public Sub Conv_RefType()
Dim Conv As String
Dim Mycell As Range
Dim MyFormula
Dim NewFormula
Dim MyMsg, MyTitle, MyBox
'Prompt user to change to relative or absolute references
10 Conv = Application.InputBox _
("Type A to convert to Absolute, R to Relative Reference(s)", _
"Change Cell Reference Type")
'If changing relative to absolute references
20 If UCase(Conv) = "A" Then
'Loop through each cell selected
30 For Each Mycell In Selection
40 If Len(Mycell.Formula) > 0 Then
'Stores cell's formula as variable
50 MyFormula = Mycell.Formula
'Converts formula to absolute reference style
60 NewFormula = Application.ConvertFormula _
(Formula:=MyFormula, _
fromReferenceStyle:=xlA1, _
toReferenceStyle:=xlA1, _
toAbsolute:=xlAbsolute)
'Replaces old formula with new absolute formula
70 Mycell.Formula = NewFormula
80 End If
90 Next
'If changing absolute to relative references
100 ElseIf UCase(Conv) = "R" Then
'Loop through each cell selected
110 For Each Mycell In Selection
120 If Len(Mycell.Formula) > 0 Then
'Stores cell's formula as variable
130 MyFormula = Mycell.Formula
'Converts formula to relative reference style
140 NewFormula = Application.ConvertFormula _
(Formula:=MyFormula, _
fromReferenceStyle:=xlA1, _
toReferenceStyle:=xlA1, _
toAbsolute:=xlRelative)
'Replaces old formula with new relative formula
150 Mycell.Formula = NewFormula
160 End If
170 Next
'Display Error message if choice entered is invalid
180 ElseIf UCase(Conv) <> "FALSE" Then
190 MyMsg = "Enter A for Absolute, R for Relative Reference(s)"
200 MyTitle = "Option Not Valid"
210 MyBox = MsgBox(MyMsg, 0, MyTitle)
220 End If
End Sub