Copy multiple first non blank cells in data with gaps
Results 1 to 4 of 4

Thread: Copy multiple first non blank cells in data with gaps
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Sep 2018
    Location
    scotland
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Copy multiple first non blank cells in data with gaps

    Hi all,

    I have to columns of data and I am looking to copy the first non blank value and move it to the adjacent cell. The raw data looks like this:

    -1
    0
    -1
    -2
    -3
    -2
    -1
    0
    1
    2
    3
    4
    3
    4
    5
    4
    3
    2
    1
    0
    1
    0
    1

    In the first instance I would like to copy -3 in the 2nd column and paste it under the -2 in the first column.
    Then copy the 2 in the first column (2nd set of rows) and paste it underneath the 1 in the first set of data in the 2nd column.
    And so on (for a variable number of times)

    Below I have highlighted the values in the above example:
    -1
    0
    -1
    -2
    -3 -3
    -2
    -1
    0
    1
    2 2
    3
    4
    3
    4
    5 5
    4
    3

    Many thanks!

  2. #2
    MrExcel MVP
    Join Date
    Jan 2008
    Posts
    14,834
    Post Thanks / Like
    Mentioned
    26 Post(s)
    Tagged
    12 Thread(s)

    Default Re: Copy multiple first non blank cells in data with gaps

    Perhaps this:-
    Code:
    Sub MG13Dec47
    Dim Rng As Range, R As Range
     Set Rng = Range("A:A").SpecialCells(xlCellTypeBlanks)
     For Each R In Rng.Areas
        R(1) = R(1).Offset(, 1)
        R(R.Count)(1).Offset(1, 1) = R(R.Count + 1)
    Next R
    End Sub
    Regards Mick

  3. #3
    New Member
    Join Date
    Sep 2018
    Location
    scotland
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy multiple first non blank cells in data with gaps

    Mick that works perfectly! I have no idea what it means or how to read it however thank you very much!

    I did try to record a macro by using ctrl+down arrow to get to bottom of data set, copy the desired value, arrow left (or right depending on which column I was in - it would alternate each time), then paste.....however I didn't know how to make this loop until no values were remaining.

    Again thanks for your help.

    All the best.

    Marc

  4. #4
    MrExcel MVP
    Join Date
    Jan 2008
    Posts
    14,834
    Post Thanks / Like
    Mentioned
    26 Post(s)
    Tagged
    12 Thread(s)

    Default Re: Copy multiple first non blank cells in data with gaps

    You're welcome

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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