En makro til formålet kunne eksempelvis se sådan her ud:
Sub sub_bytte_plads() Dim i_cell_count As Integer Dim rng_cell_x As Range Dim var_cell_1 As Variant Dim var_cell_2 As Variant Dim rng_cell_1 As Range Dim rng_cell_2 As Range Dim b_fejl As Boolean For Each rng_cell_x In Selection.Cells i_cell_count = i_cell_count + 1 If i_cell_count > 2 Then b_fejl = True Exit For End If If rng_cell_1 Is Nothing Then Set rng_cell_1 = rng_cell_x var_cell_1 = rng_cell_x.Formula2R1C1 ElseIf rng_cell_2 Is Nothing Then Set rng_cell_2 = rng_cell_x var_cell_2 = rng_cell_x.Formula2R1C1 End If Next rng_cell_x If Not rng_cell_1 Is Nothing And Not rng_cell_2 Is Nothing Then rng_cell_1.Formula2R1C1 = var_cell_2 rng_cell_2.Formula2R1C1 = var_cell_1 Else b_fejl = True End If If b_fejl Then MsgBox "Der skal markeres to celler - hverken flere eller færre", vbOKOnly + vbInformation, "Forkert antal celler valgt" End If End Sub
Hvis cellerne støder lige op ad hinanden kan du gøre det med [Shift] tasten og musen, men støder cellerne ikke op ad hinanden er du nødt til at benytte en makro kode.
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.