Moving Cells

D

DaveB

I have 3,000 rows in my worksheet. I just want to move
every other row up one line:

Smith, John (cell A1)
Biology Dept (cell A2)

I want to move cell A2 to B1...and

Jones, Sam (cell A3)
Anesth Dept (cell A4)

I want to move cell A4 to B3..and so on throughout my
worksheet. Thanks for the code in advance.

DaveB
 
B

Bob Phillips

Hi Dave,

A simple macro

Sub MoveEm()
Dim i As Long
Dim cLastRow As Long
Dim rng As Range

Application.ScreenUpdating = False
cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(1, "B").Value = Cells(2, "A").Value
Set rng = Range("A2")
For i = 3 To cLastRow Step 2
Cells(i, "B").Value = Cells(i + 1, "A").Value
Set rng = Union(rng, Cells(i + 1, "A"))
Next i
rng.EntireRow.Delete
Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top