If only some of the cells are to be
changed, this routine will do the job.
Make changes to mirror the actual
setup in
Col = "B"
ChangeCells = Array(22, 25)
WithCells = Array(96, 48)
The routine is inserted in a general module:
From the sheet: <Alt><F11>, menu: Insert >
Module, copy and paste the code to the
righthand window.
Return to the sheet with <Alt><F11>,
save the workbook and run the code from
Tools > Macro > Macros.
It is assumed, that the cells to be changed
do not contain formulae.
Sub ChangeRows()
'Leo Heuser, 1 Feb. 2004
Dim ChangeCells As Variant
Dim Col As String
Dim Counter As Long
Dim Dummy As Variant
Dim WithCells As Variant
Col = "B"
ChangeCells = Array(22, 25)
WithCells = Array(96, 48)
With ActiveSheet
For Counter = LBound(ChangeCells) To UBound(ChangeCells)
Dummy = .Cells(ChangeCells(Counter), Col).Value
.Cells(ChangeCells(Counter), Col).Value = _
.Cells(WithCells(Counter), Col).Value
.Cells(WithCells(Counter), Col).Value = Dummy
Next Counter
End With
End Sub