Transfer only selected row data.

harzer

Board Regular
Joined
Dec 15, 2021
Messages
122
Office Version
  1. 2016
Platform
  1. Windows
Hello,
My data contains many variable rows across multiple columns.
The data that we are going to process in this case here, of course concerns all the rows on the first 10 columns only, the columns from the 11th are not taken into account.
I have two sheets, the first is "Parents" contains the data, the second is "Result".
I want to copy the rows selected in column "A" in the "Parents" sheet to copy them to the "Result" sheet.
Two conditions to be met for the transfer of lines:
If the "Result" sheet does not contain data, the copy will be made from line 2.
If the "Result" sheet already contains data, the copy will be made at the first empty line, so we keep the data that already exists.
I allow you to ask for a solution either with UBound, or dictionary, or both combined so that the transfer is done quickly.
Cheers.

To test, we will copy two lines, see below :

Transfert.xlsm
ABCDEFGHIJKLM
1JeunesPèreMèreEleveurAgeVolièreCageToursInformationAncêtresPèresMères
2ElA27-001/2022 MMaN-008/2021 MElA27-021/2020 FTress Gabyx5H723-04-224TMâleABC
3YLM03-002/2022 FMaN-024/2021 MElA27-016+/2020 FRoland Louisx4H826-04-224TFemelle Tte JauneAABBCC
4MPO65-003/2022 MMaN-024/2021 MElA27-016+/2020 FRoland Louisx5H826-04-224TFemelle Tte JauneABC
5ElA27-004/2022 FMaN-024/2021 MElA27-016+/2020 FRoland Louisx5H826-04-224TFemelle avec tacheAABBCC
6WQA69-005/2022 FMaN-024/2021 MElA27-016+/2020 FTress Gabyx4H802-05-224TFemelle Tte jauneABC
7ElA27-006/2022 MMaN-024/2021 MElA27-016+/2020 FRoland Louisx5H802-05-224TMâle Tt jaune AABBCC
8GTE87-007/2022 FElA27-010/2021 MMaN-034/2021 FCardon Léox4H525-04-224TFemelle Tte jauneABC
9ElA27-008/2022 MElA27-010/2021 MMaN-034/2021 FRoland Louisx5H525-04-224TMâle Tt jauneAABBCC
10MaN-008/2022 FMaN-002/2020 MMaN-020/2020 FCardon Léox4H2224-04-224TFemelle ABC
11ElA27-009/2022 FElA27-010/2021 MMaN-034/2021 FRoland Louisx4H525-04-224TFemelle Tte jauneAABBCC
12MAO25-010/2022 MElA27-010/2021 MMaN-034/2021 FRoland Louisx5H525-04-224TMâle Tt jauneABC
13ElA27-011/2022 FElA27-010/2021 MMaN-034/2021 FRoland Louisx4H525-04-224TFemelle Tte jauneAABBCC
14HGF-012/2022 FElA27-006/2021 MElA27-021/2020 FCardon Léox4H708-06-224TFemelle Tte jauneABC
15ElA27-013/2022 MElA27-006/2021 MElA27-052/2021 FRoland Louisx5H326-04-224TMâle Tache aile gaucheAABBCC
16URD12-014/2022 FElA27-006/2021 MElA27-052/2021 FRoland Louisx4H326-04-224TFemelle Tte jauneABC
17FEQ47-015/2022 FElA27-006/2021 MElA27-052/2021 FMaes Voncentx5H326-04-224TFemelle Tte JauneAABBCC
18KLP12-016/2022 FElA27-006/2021 MElA27-052/2021 FRoland Louisx4H326-04-224TFemelle Tte jauneABC
19ElA27-017/2022 MMaN-005/2021 MElA27-068/2021 FRoland Louisx5H428-04-224TMâle Tte jauneAABBCC
20BIM13-018/2022 MMaN-005/2021 MElA27-068/2021 FDerouck Léox5H428-04-224TMâle Tt jauneABC
Parents

Transfert.xlsm
A
6WQA69-005/2022 F
Parents

Transfert.xlsm
A
20BIM13-018/2022 M
Parents


Here is the result to get :

Transfert.xlsm
ABCDEFGHIJ
1JeunesPèreMèreEleveurAgeVolièreCageToursInformation
2WQA69-005/2022 FMaN-024/2021 MElA27-016+/2020 FTress Gabyx4H802-05-224TFemelle Tte jaune
3BIM13-018/2022 MMaN-005/2021 MElA27-068/2021 FDerouck Léox5H428-04-224TMâle Tt jaune
Resultat
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Transfer only selected row data.
When you say "selected row", do you mean that you will highlight the rows to be transferred? Please clarify in detail.
 
Upvote 0
Hello,
Thank you for your reply.
Yes, that's right, I highlight the rows to transfer by choosing the cells of the rows concerned in column "A".
 
Upvote 0
Try:
VBA Code:
Sub CopyData()
    Application.ScreenUpdating = False
    Dim desWS As Worksheet
    Set desWS = Sheets("Resultat")
    Intersect(Columns(1).Resize(, 10), Selection.EntireRow).Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1)
    Application.ScreenUpdating = False
End Sub
 
Upvote 0
Solution
Hello mumps,
Thanks for your code.
It gives me the right result and meets my expectation.
Big THANKS to you.
Cheers.
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,216,732
Messages
6,132,409
Members
449,726
Latest member
Skittlebeanz

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