Consulting

Results 1 to 6 of 6

Thread: Moving cells from 1 line to another

  1. #1
    VBAX Newbie
    Joined
    Feb 2010
    Posts
    4
    Location

    Moving cells from 1 line to another

    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

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    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:
    [VBA]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[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Newbie
    Joined
    Feb 2010
    Posts
    4
    Location
    That is correct yes and then delete the row where A does not have the entry.

    Thanks

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Does my solution above work for you?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Newbie
    Joined
    Feb 2010
    Posts
    4
    Location
    Im just going to try it, cheers

  6. #6
    VBAX Newbie
    Joined
    Feb 2010
    Posts
    4
    Location
    slight edit but works fine.

    Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •