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
 
Hi Mr JoeMo

This is the code with ranges that i'm using with the following ranges on report and excel helper
-.The report start on row 3 (Col 20 to 40)
-.The Excel Helper data start on Row 4 (Col 58 to 78 )


Code:
Sub ReporTest()   'ReporTrack_1_JP_NS
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



Best Regards

David
 
Last edited:
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Mr JoeMo

Yes sir, your code it work like a Charm !!!
My Apologize to bother that much. :)

Here is your code

Code:
Sub ReporTest()' Code done by Mr JoeMo, www.mrexcel.com 
Dim j As Long, lR 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
    lR = Range("AG" & Rows.Count).End(xlUp).Row
    With Range("T2:AN" & lR)
        .Sort key1:=[AG3], order1:=xlDescending, Header:=xlYes
    End With
End Sub


Thank you so much !!!



Best Regards from Miami

David G.
 
Upvote 0
Hi Mr JoeMo

Yes sir, your code it work like a Charm !!!
My Apologize to bother that much. :)

Here is your code

Code:
Sub ReporTest()' Code done by Mr JoeMo, www.mrexcel.com 
Dim j As Long, lR 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
    lR = Range("AG" & Rows.Count).End(xlUp).Row
    With Range("T2:AN" & lR)
        .Sort key1:=[AG3], order1:=xlDescending, Header:=xlYes
    End With
End Sub


Thank you so much !!!



Best Regards from Miami

David G.
You are welcome - thanks for the reply.
 
Upvote 0

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

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