Jeg fandt nedenstående makro hos Microsoft, og den ændrer relative referencer til absolutte - eller omvendt - på markeret område. Har afprøvet den. Meget let at bruge.
'Convert_Reference Type Macro 'A Visual Basic module to convert absolute references to relative 'references or relative references to absolute references.
Sub Conv_RefType() Dim Conv As String 'Prompt user to change to relative or absolute references Conv = Application.InputBox _ ("Type A to convert to Absolute, R to Relative Reference(s)", _ "Change Cell Reference Type") 'If changing relative to absolute references If UCase(Conv) = "A" Then 'Loop through each cell selected For Each Mycell In Selection If Len(Mycell.Formula) > 0 Then 'Stores cell's formula as variable MyFormula = Mycell.Formula 'Converts formula to absolute reference style NewFormula = Application.ConvertFormula _ (Formula:=MyFormula, _ fromReferenceStyle:=xlA1, _ toReferenceStyle:=xlA1, _ toAbsolute:=xlAbsolute) 'Replaces old formula with new absolute formula Mycell.Formula = NewFormula End If Next 'If changing absolute to relative references ElseIf UCase(Conv) = "R" Then 'Loop through each cell selected For Each Mycell In Selection If Len(Mycell.Formula) > 0 Then 'Stores cell's formula as variable MyFormula = Mycell.Formula 'Converts formula to relative reference style NewFormula = Application.ConvertFormula _ (Formula:=MyFormula, _ fromReferenceStyle:=xlA1, _ toReferenceStyle:=xlA1, _ toAbsolute:=xlRelative) 'Replaces old formula with new relative formula Mycell.Formula = NewFormula End If Next 'Display Error message if choice entered is invalid ElseIf UCase(Conv) <> "FALSE" Then MyMsg = "Enter A for Absolute, R for Relative Reference(s)" MyTitle = "Option Not Valid" MyBox = MsgBox(MyMsg, 0, MyTitle) End If End Sub
1. Marker området med formler (inklusive eventuelt blanke celler). 2. Tryk på F5, tryk på Special, sæt prik ved Formulas og tryk OK. 3. Marker hele formlen i formelfeltet og tryk på F4. 4. Hold Ctrl tasten nede og tryk på Enter.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.