Copy ROW from one spreadsheet to another

alm395

New Member
Joined
Apr 23, 2018
Messages
39
Office Version
  1. 365
Platform
  1. Windows
I have a report I am working on. One sheet named "BlueSkyDATA" has the raw data I am pulling from. It has 19 columns (A-S) and hundreds of rows. If the time data in column K is greater than or equal to 1 hour, I would like that whole row to be copied to another spreadsheet in the same workbook, called "Dispatched" beginning at A4. How can I do this?

Thanks so much, in advance!
Ann
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Show us how this time data in column K will appear:

Will it Look like this 1:15
 
Upvote 0
Try this:
Code:
Sub New_Filter()
'Modified 4-23-18 4:25 PM EDT
Application.ScreenUpdating = False
Sheets("BlueSkyDATA").Activate
    With ActiveSheet.Range(Cells(1, "K"), Cells(Cells(Rows.Count, "K").End(xlUp).Row, "K"))
        .AutoFilter Field:=1, Criteria1:=">=" & TimeValue("01:00:00")
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Dispatched").Range("A4")
        .AutoFilter
    End With
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0
If you plan to run the script more then once. And you want to append the data to the sheet named Dispatched
You will need to us this script.
First time data will start on row (4) next time first row after last row

Code:
Sub New_Filter()
'Modified 4-23-18 4:50 PM EDT
Application.ScreenUpdating = False
Sheets("BlueSkyDATA").Activate
Dim Lastrow As Long
Lastrow = Sheets("Dispatched").Cells(Rows.Count, "K").End(xlUp).Row + 1
If Lastrow < 4 Then Lastrow = 4

    With ActiveSheet.Range(Cells(1, "K"), Cells(Cells(Rows.Count, "K").End(xlUp).Row, "K"))
        .AutoFilter Field:=1, Criteria1:=">=" & TimeValue("01:00:00")
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Dispatched").Cells(Lastrow, "A")
        .AutoFilter
    End With
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0
@My Answer is This
I had to tweak it a tiny bit, but it works!!! Thank you soo much! That just saved me so much time and a big 'ol headache! You are the BEST!!!
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
@My Answer is This
I had to tweak it a tiny bit, but it works!!! Thank you soo much! That just saved me so much time and a big 'ol headache! You are the BEST!!!
 
Upvote 0
I have another question...would it be possible to add to this same macro the same data in cells L (what we currently have) but add columns M, & N (the >= 1:00:00 timeframe), then copy those lines to the "Dispatched" spreadsheet, and do this each time the workbook is opened...then remove any duplicates that may occur on the "Dispatched" spreadsheet? The most important part of that is the copying the rows if L, M, & N are greater than or equal to the 1-hour mark. I hope that makes sense. Please advise.
 
Upvote 0
Now your wanting a lot more then your original post.
Now we need to see if L M and N are greater then.
And I'm not sure what you mean by duplicates.

You want to look in every single row and see if the row is a exact duplicate of any of the other rows.

That would mean looking in 19 columns on hundreds of rows to see if there are exact duplicates.
This is beyond my knowledgebase.
I will continue to monitor this thread to see what I can learn.
 
Upvote 0
Try this:
For the first part of your new request.
Code:
Sub New_Filter()
'Modified 4-27-18 10:53 PM EDT
Application.ScreenUpdating = False
Sheets("BlueSkyDATA").Activate
Dim Lastrow As Long
Lastrow = Sheets("Dispatched").Cells(Rows.Count, "L").End(xlUp).Row + 1
If Lastrow < 4 Then Lastrow = 4

    With ActiveSheet.Range(Cells(1, "L").Resize(, 3), Cells(Cells(Rows.Count, "L").End(xlUp).Row, "L"))
        .AutoFilter Field:=1, Criteria1:=">=" & TimeValue("01:00:00")
         .AutoFilter Field:=2, Criteria1:=">=" & TimeValue("01:00:00")
          .AutoFilter Field:=3, Criteria1:=">=" & TimeValue("01:00:00")
         
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Dispatched").Cells(Lastrow, "A")
        .AutoFilter
    End With
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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