VBA to copy entire row and paste in another sheet if condition is met

aliaslamy2k

Active Member
Joined
Sep 15, 2009
Messages
416
Office Version
  1. 2019
Platform
  1. Windows
Dear Experts,

I am looking for a VBA to copy entire row from ( Sheet Name: System Report) if date is less than 25 Jun 2023 and paste in another sheet (Sheet name: Exp Passport)
Also if same VBA can highlight the entire row in yellow in (Sheet Name: System Report) would be great.

COPY FROM:

DesignationFamily Name/Last nameFirst Given NameSecond Given NameContactPPT NoPassport Expiry Date
aa1bb1cc1dd1ee1AB12345618/12/2022
aa2bb2cc2dd2ee2AB12345729/11/2028
aa3bb3cc3dd3ee3AB12345817/07/2022
aa4bb4cc4dd4ee4AB12345924/08/2025
aa5bb5cc5dd5ee5AB12346026/03/2029
aa6bb6cc6dd6ee6AB12346131/10/2020
aa7bb7cc7dd7ee7AB1234624/2/2022
aa8bb8cc8dd8ee8AB12346314/03/2023
aa9bb9cc9dd9ee9AB12346413/04/2028
aa10bb10cc10dd10ee10AB12346522/12/2022
aa11bb11cc11dd11ee11AB12346616/12/2023
aa12bb12cc12dd12ee12AB12346711/3/2019
aa13bb13cc13dd13ee13AB12346825/06/2024
aa14bb14cc14dd14ee14AB12346917/12/2024
aa15bb15cc15dd15ee15AB12347023/04/2029
aa16bb16cc16dd16ee16AB12347124/04/2019
aa17bb17cc17dd17ee17AB12347213/05/2025
aa18bb18cc18dd18ee18AB12347325/02/2031
aa19bb19cc19dd19ee19AB12347414/12/2022
aa20bb20cc20dd20ee20AB12347513/01/2024
aa21bb21cc21dd21ee21AB12347628/07/2031
aa22bb22cc22dd22ee22AB12347721/02/2025
aa23bb23cc23dd23ee23AB12347804/02/2025
aa24bb24cc24dd24ee24AB12347918/06/2015
aa25bb25cc25dd25ee25AB12348024/05/2032



PASTE HERE

DesignationFamily Name/Last nameFirst Given NameSecond Given NameContactPPT NoPassport Expiry Date



Thank You so much in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I don't know that VBA is really necessary here. This can be accomplished quite easily without it.

For the copying/pasting, you could simply use Advanced Filters, which allows you do filter data and copy it to another location (sheet).
Simply filter on your date field.
See: How to copy data to another worksheet with Advanced Filter in Excel?
Note at the bottom of that link, they also show you how to apply this with VBA code, if you really want that.

And for your second part, highlighting the copied rows in yellow, you can simply use Conditional Formatting to do that.
Simply highlight all the rows meeting your date criteria.

Note: Your date column looks a little funny. The fact that you have some date right-justified and some left-justified seems to suggest that you have a mixture of valid date entries, and dates entered as text. You will need to fix that up, as the "dates entered as text" will not be treated as dates and not work right.
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

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