VBA - copy specific rows from one to worksheet to another worksheet

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,502
Office Version
  1. 2016
Platform
  1. Windows
Hello Friends,

I am looking for a VBA code which could copy specific rows from one worksheet (Database) to another worksheet (Running order Status) within the same workbook

1) Copy from Database sheet to Running Order Status Sheet only rows where Column G (Status) showing In Process
2) Copy starting from Range("A4") till the last used row in Column A & paste only values in the Running Order Status sheet starting from Range("A4")

VBA Working.xlsm
ABCDEFGH
3P.O #REFP.O.DATECustomerSuppliers Values STATUS Actual Ship DATE
415556937 A58112-Nov-20aa $ 330.00 Shipped18-Mar-21
5AH 27615 B158210-Dec-20bb $ 33,155.86 Shipped30-Apr-21
635776758329-Dec-20xxxx $ 32,325.12 Shipped30-Jun-21
715590409 A58412-Dec-20dd $ 9,055.20 Shipped10-Feb-21
815624644 A + 1565765058511-Jan-21aa $ 14,256.00 Shipped15-Mar-21
9586 A58630-Jan-21bb $ 21,700.80 Shipped10-Mar-21
103877625877-Apr-21aa $ 86,355.36 In Process
1136261458820-Apr-21bb $ 854,027.12 In Process
123798455896-Apr-21xxxx $ 339,365.12 In Process
133629435909-Apr-21dd $ 316,199.36 In Process
1415701543 A + 1570313759117-Mar-21aa $ 9,801.00 Shipped17-May-21
1536335959220-Apr-21bb $ 495,914.94 In Process
1615740842 A59317-Apr-21aa $ 11,616.00 Shipped11-Jun-21
1715713419 A59427-Mar-21bb $ 455.04 Shipped28-Jun-21
1815758298 A59528-Apr-21xxxx $ 810.54 Shipped28-Jun-21
193703435962-Jun-21dd $ 958,451.40 In Process
2037033659712-May-21aa $ 150,520.68 In Process
2137008959821-May-21bb $ 263,648.00 In Process
2237009059921-May-21aa $ 259,732.00 In Process
2315774900 A6007-May-21bb $ 11,510.40 Shipped9-Jul-21
2415774893 A6017-May-21xxxx $ 476.37 Shipped28-Jun-21
253702876029-Jun-21dd $ 315,970.91 In Process
2639703360317-Jun-21aa $ 299,574.32 In Process
273704136047-Jun-21bb $ 241,284.96 In Process
2860560527-May-21aa $ 25,432.00 Shipped8-Jul-21
293698056068-Jun-21bb $ 394,185.00 In Process
3015823899 A60714-Jun-21cc $ 11,536.80 In Process
Database



VBA Working.xlsm
ABCDEFGH
1
2
3P.O #REFP.O.DATECustomerSuppliers Values STATUS Actual Ship DATE
43877625877-Apr-21aa $ 86,355.36 In Process
536261458820-Apr-21bb $ 854,027.12 In Process
63798455896-Apr-21xxxx $ 339,365.12 In Process
73629435909-Apr-21dd $ 316,199.36 In Process
836335959220-Apr-21bb $ 495,914.94 In Process
93703435962-Jun-21dd $ 958,451.40 In Process
1037033659712-May-21aa $ 150,520.68 In Process
1137008959821-May-21bb $ 263,648.00 In Process
1237009059921-May-21aa $ 259,732.00 In Process
133702876029-Jun-21dd $ 315,970.91 In Process
1439703360317-Jun-21aa $ 299,574.32 In Process
153704136047-Jun-21bb $ 241,284.96 In Process
163698056068-Jun-21bb $ 394,185.00 In Process
1715823899 A60714-Jun-21cc $ 11,536.80 In Process
Running Order Status


Any help would be appreciated

Regards,

Humayun
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
How about
VBA Code:
Sub hrayani()
   With Sheets("Database")
      .Range("A3:H3").AutoFilter 7, "In Process"
      .AutoFilter.Range.Offset(1).Copy
   End With
   Sheets("Running Order Status").Range("A4").PasteSpecial , xlPasteValues
   Application.CutCopyMode = False
End Sub
 
Upvote 0
Hi Fluff,

Thanks for the reply
I am getting error with this of the code highlighted - Run time error 1004... PAstespecial method of range class failed
VBA Code:
Sheets("Running Order Status").Range("A4").PasteSpecial , xlPasteValues

One more thing as I requested in my initial post that instead of looking from A3:AH3 it should look from A3 till the last used row in Column A as the database will keep on growing
 
Upvote 0
Remove the comma from that line.

As long as you don't have any blank rows rows in the data the code will automatically filter the entire data.
 
Upvote 0
Thanks Worked for me...

Remove the comma from that line.

As long as you don't have any blank rows rows in the data the code will automatically filter the entire data.

Thanks Fluff

Now working just Perfect
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.
Hi,
sorry for this but i noticed it just now

can we move that auto filter from the database sheet when the copy paste is done
I want the database sheet to be as it was

EDIT:

just added this line & it worked

VBA Code:
.AutoFilterMode = False
 
Last edited:
Upvote 0
Yup, like
VBA Code:
Sub hrayani()
   With Sheets("Database")
      .Range("A3:H3").AutoFilter 7, "In Process"
      .AutoFilter.Range.Offset(1).Copy
      .AutoFilterMode = False
   End With
   Sheets("Running Order Status").Range("A4").PasteSpecial xlPasteValues
   Application.CutCopyMode = False
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,216,163
Messages
6,129,223
Members
449,495
Latest member
janzablox

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