Copy multiple columns from one worksheet to another with different rows in each worksheet

ala12345

New Member
Joined
Mar 16, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm new to the board and a newbie to VBA. I tried different approaches found online but seems none of mine works.

So here is my questions: I need to copy 5 columns from Worksheet A to Worksheet B. The columns in worksheet A and B have different rows: let's assume wsA has 20 rows and wsB has 10 rows but they are not fixed. The only identical column in both sheets are their IDs so we may need to use IDs to match first, then do the copy.


I tried:
1. wsA.Range("B2:F").Copy destination wsB.Range("C2:G")
wsA.Range("B2:F").Copy
2. wsB.Range("C2:G").PasteSpecials
3. wsA.Range(wsA.Cells(1, "B"), wsA.Cells(wsA.Rows.Count, "F").End(xlUp)).Copy
wsB.range(“E1”).Insert xlShiftDown
4. For i=1 to lastrowA
For j=1 to lastrow B
If wsA.Cells(IDs).Value = wsB.Cells(IDs).Value Then
wsA.Cells(i,2).Value = wsB.Cells(j,3).Values

Can someone help

Thank you!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,099
Messages
6,170,112
Members
452,302
Latest member
TaMere

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