VBA: find data in row, cut, and paste to a specific row above (same column)

L

Legacy 171839

Guest
Hi all,

Pulling the hair I have left out.

I have several rows of data, making up a working day in 5 min increments.

I want to copy and paste the data from the lower rows into the 1st row, to finish with 1 line of data for the day.

If there is an over lap, the data from the lines below should take precedence.

Example of the data I have, and what I want the macro to do are in the 2 tables below.

I hope I have been able to articulate what I am trying to acheive in a way that makes sense.

Any help at all will be greatly received.

Kind regards
JohnJohnJohnJohnJohnJohn
DaveDaveDaveDave
PetePete
AlexAlexAlexAlex

<tbody>
</tbody>


JohnJohnDaveDaveDaveDavePetePeteJohnAlexAlexAlexAlex

<tbody>
</tbody>
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You could use a nested IF function in Excel (without VBA):
=IF(A5<>"",A5,IF(A4<>"",A4,IF(A3<>"",A3,IF(A2<>"",A2,A1))))

Perhaps this does the trick for you? A VBA solution will also be fairly straightforward I think, but if it's not necessary I would stick to Excel functions.

Does this help you at all?
 
Upvote 0
Try this:-
Code:
Dim Rng As Range, Dn As Range
For Each Dn In UsedRange
    If Not IsEmpty(Dn) Then
        Cells(1, Dn.Column) = Dn
    End If
Next Dn
UsedRange.Offset(1).Delete
 
Upvote 0
Thank you both for your help.

JLeno - of course, I was looking so hard for a VBA fix, I missed the obvious solution....

Thanks alot, great help indeed...!
 
Upvote 0

Forum statistics

Threads
1,217,040
Messages
6,134,152
Members
449,861
Latest member
DMJHohl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top