How to copy rows to the next sheet if a condition is met?

Status
Not open for further replies.

Noni

Board Regular
Joined
Aug 27, 2022
Messages
63
Office Version
  1. 2021
Platform
  1. Windows
Hi there,

Data is in Sheet1 and Sheet2 is where I am copying rows if a condition is met.

The data (cell range) that need to be copied is in B:F (2022 client data).

If the last year’s client is also a client in this year 2022 then I want to move that client’s detail (which is in B:F) to Sheet2. Once all the last year’s 2021 clients are checked then copy new clients (2022) data to Sheet 2.

Below: blue highlighted rows are those which are clients in both 2021 and 2022 so their data gets copied first in Sheet2. Green highlighted ones are new clients, so their details get copied after in Sheet2. And in column A, non-highlighted ones are no longer our client, so we don’t copy them to Sheet2.

It is also important to keep the same order. By this I mean, that Sheet2 must have the old client details (which have met the above condition) first and in the same order as they appear in Sheet1 column A. Then new clients’ details go at the bottom of Sheet2. i.e. Peter who is a client in 2021-2022 gets copied first in sheet2. Then Sally goes to Sheet2, and then Michelle ….

Sheet 1
VBA.xlsx
ABCDEF
12021 client 2022 client 2022 client BB2022 client Cons2022 client Bld2022 client Other
2JamesMichael12341234234512
3SamSarah4321546734
4PeterMary98760340
5ShawRachel56781245877
6SallyAnna7834230345
7MichelleMonica235645451245
8IvonaCharles1234000
9AnnaPeter65432300
10ClaireAnthony12342300
11BenBen123456340
12MichaelElizabeth654307845
13DavidWong1276234561267
14AnnaleiseSally9854235689
15ChrisJay432587658934
16JohnMichelle126512566456
17BobDavid12761234323
18AnthonyJennifer123487655656
19SueSue8765347834
20RobinRuba325423978
21Henry98767800
22Chloe32453456760
23Candy238935650
Sheet1


Sheet 2
VBA.xlsx
ABCDE
12022 client 2022 client BB2022 client Cons2022 client Bld2022 client Other
2Peter65432300
3Sally9854235689
4Michelle126512566456
5Anna7834230345
6Ben123456340
7Michael12341234234512
8David12761234323
9Anthony12342300
10Sue8765347834
11Sarah4321546734
12Mary98760340
13Rachel56781245877
14Monica235645451245
15Charles1234000
16Elizabeth654307845
17Wong1276234561267
18Jay432587658934
19Jennifer123487655656
20Ruba325423978
21Henry98767800
22Chloe32453456760
23Candy238935650
Sheet2
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Status
Not open for further replies.

Forum statistics

Threads
1,214,397
Messages
6,119,271
Members
448,882
Latest member
Lorie1693

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