VBA to select and copy rows to new sheet based on a formula

Anandpersad

New Member
Joined
Oct 18, 2014
Messages
31
Hi All,
I am looking for a vba which will do the following:
Daily I get a list with data. The numbers of rows differs daily. From 10.000 rows to 18.000 rows.
I am looking for the following:
· VBA to check the dates in column AO and date in columns AP. If date in column AO > AP, select row and copy row to a Sheet called “date”. If there are more than one row, all have to be selected and copied to sheet “Date”
· VBA to check the amounts. Amounts are in column AA and column X. If the difference between AA and X (AA-X) is less than zero, select row and copy to sheet “Amount”. If there are more than one row, all have to be selected and copied to sheet “Amount”

Hoping someone can help me out here.


Thanks and Regards,

Anand
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hey,

there probably is a faster way of doing it, but you could give this a try

Code:
Sub devideRows()
Dim LastRow As Long
Dim LRowDest As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To LastRow
If Cells(i, "AA").Value - Cells(i, "X").Value < 0 Then
    LRowDest = Worksheets("Amount").Cells(Rows.Count, "A").End(xlUp).Row
    Rows(i).EntireRow.Copy _
    Destination:=Worksheets("Amount").Range("A" & LRowDest + 1)
End If
If Cells(i, "AO").Value > Cells(i, "AP").Value Then
    LRowDest = Worksheets("Date").Cells(Rows.Count, "A").End(xlUp).Row
    Rows(i).EntireRow.Copy _
    Destination:=Worksheets("Date").Range("A" & LRowDest + 1)
End If
Next
Application.ScreenUpdating = True
End Sub

Julian
 
Upvote 0

Forum statistics

Threads
1,215,710
Messages
6,126,396
Members
449,312
Latest member
sweetfriend9

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