PDA

View Full Version : Moving cells from 1 line to another



Swarv
02-24-2010, 02:28 AM
Hi all,

I have a sheet with quite a few records.
In Column A is the title of the person but there are some gaps. i.e. Row 5228 might not have a title in it.
when I get to this row can I copy the cells B5228, C5228, D5228, E5228, F5228 and place them in L5227, M5227, N5227, O5227, P5227 ?

Then Delete the line 5228?

Im sure this is possible but not sure how.

Thanks

Martin

Simon Lloyd
02-24-2010, 03:32 AM
So as i see it if Axxx does not have an entry you want to place all entries from that row (B:F) to minus 1 row (L:P) is that correct? if it is this will do:
Sub del_n_move()
For i = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row To 3 Step -1
If ActiveSheet.Range("A" & i).Value = "" Then
ActiveSheet.Range("B" & i & ":" & "F" & i).Copy Destination:=ActiveSheet.Range("L" & i - 1 & ":" & "P" & i - 1)
ActiveSheet.Range("A" & i).EntireRow.Delete
End If
Next i
End Sub

Swarv
02-24-2010, 03:45 AM
That is correct yes and then delete the row where A does not have the entry.

Thanks

Simon Lloyd
02-24-2010, 03:55 AM
Does my solution above work for you?

Swarv
02-24-2010, 04:14 AM
Im just going to try it, cheers

Swarv
02-24-2010, 04:50 AM
slight edit but works fine.

Thank you very much.