modify VBA Code to shift older data down and copy newer at top

David gonzalez

New Member
Joined
Nov 19, 2013
Messages
16
Hi,

on daily basis and with aid of excel helper info I create a report (between 9 to 24 rows).
So i have a vba code that copy this Info and paste the data in next blank cell in Report area located in same sheet (but different area).
The code is working fine, except that always newer data it copy at bottom of the sheet and data is getting bigger.

Then what i need to accomplish is to modify the line of code and change the Order of copy
From Top newer (today data) and move/shift the Older (yesterday data) to Bottom.

This the actual data (see date Oct 5, oct 6, oct 7 down)

Old-2-New.png


This Is the Ideal Data with newest date at Top ( Oct 7, Oct 6, Oct 5..)
New-2-Old.png



This is the actual code

Code:
Sub ReporTrack_Test()    Dim j As Long
    For j = 4 To 12 
        If Cells(j, 58).Value > 1 And Cells(j, 58).Value < 36 Then _
        Cells(Rows.count, 20).End(xlUp).Offset(1).Resize(, 22).Value = Cells(j, 58).Resize(, 22).Value
    
    Next j
End Sub


Thank you !


Best Regards

David
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This will sort your data on the date column - will that work for you?
Code:
Sub ReporTrack_Test()
Dim j As Long
    For j = 4 To 12
        If Cells(j, 58).Value > 1 And Cells(j, 58).Value < 36 Then _
        Cells(Rows.Count, 20).End(xlUp).Offset(1).Resize(, 22).Value = Cells(j, 58).Resize(, 22).Value
    
    Next j
    With Range("AG2")
        .Sort key1:=[AG3], order1:=xlDescending, Header:=xlYes
    End With
End Sub
 
Upvote 0
Hi mr joemo,

It copy first 3 line of report, but it pop a run-time error 1004, "This operation requires the merged cell to be identically sized",
and the debug highlight this line:

Code:
 .Sort key1:=[AG3], order1:=xlDescending, Header:=xlYes


Best Regards

David
 
Upvote 0
Hi Mr Joemo,

Is strange, the excel helper source and Report, i select the whole range and make sure that is not data merged,
and still the same error. hope to find the spot, Still checking...


Thank you



Best Regards

David
 
Upvote 0
Hi !

i check cell by cell of report and Source area (excel helper),
-.right clicked a large range from top to bottom and clear if merged cell, so Un merged (did it several times)
-.Same whole area Clear if Conditional Formatting present (just in case)
-.Set the report and Source area (excel helper) with exact same fonts and size, cells size.

and still no clue.. might i'm missing something (i don't know) Any ideas what else to check?



Best Regards

David
 
Upvote 0
Hi !

i check cell by cell of report and Source area (excel helper),
-.right clicked a large range from top to bottom and clear if merged cell, so Un merged (did it several times)
-.Same whole area Clear if Conditional Formatting present (just in case)
-.Set the report and Source area (excel helper) with exact same fonts and size, cells size.

and still no clue.. might i'm missing something (i don't know) Any ideas what else to check?



Best Regards

David
To clarify you are still getting this error: run-time error 1004, "This operation requires the merged cell to be identically sized"?

If yes, are cells in row 1 that contain REPORT merged?

Is there data beyond the images you posted in your initial post?
 
Upvote 0
Hi Mr JoeMo.

Yes sir the same error, : run-time error 1004, "This operation requires the merged cell to be identically sized"?

The report start on row 3 (Col 20 to 40)

The Excel Helper data start on Row 4 (Col 51 to 78 )

on both area including Above and bellow (just in case) i clean if Conditional formatting exist,Clean and set if cell merged, Including wrap text
set the fonts with same size, also i set the cell height and width.
But Might be i'm missing something.

P.S
i been checking for info, incluidng your post
http://www.mrexcel.com/forum/excel-questions/762499-run-time-error-1004-a.html



Thank you !


Best Regards

David
 
Upvote 0
Hi Mr JoeMo.
Initially with the picture it was the only cell merged.
but at soon i replaced the old for the new module and received the Error, i changed and check the whole thing.


Best Regards

David
 
Upvote 0
Hi Mr JoeMo.
Initially with the picture it was the only cell merged.
but at soon i replaced the old for the new module and received the Error, i changed and check the whole thing.


Best Regards

David
Hard to diagnose your problem without seeing your sheet. If you want me to look further, PM me and I will give you an email address to send me your workbook.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

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