Need VBA to automatically copy paste rows based factory selected

AronNeo

New Member
Joined
Apr 3, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Currently working on a project and been browsing through the forum last 2 days to find a solution to the problem. I am very new to VBA. thus seeking help for a full VBA code.
I would like to develop a VBA code which copies rows from table sheet1 (source file) based on" Factory" selected in the drop down list in table sheet2 (target file). i have tried array formula to get the results however the data is quite large (around 2000 rows data), therefore either it takes too long to calculate or it stops working.

below are the criteria's.
1) copies rows from source file table based on" Factory" selected in the drop down list in target file table.

2) from the source file table, only require to copy row data from column A till column F. then copy over to target file sheet table

3) there is multiple duplicate data in source file table (from column A to column F). only require to copy the unique data (remove duplicate)

attached file with generic data due to sensitivity.

Thank you in advance.
 

Attachments

  • 1000048966.png
    1000048966.png
    84.2 KB · Views: 24
  • 1000048967.png
    1000048967.png
    32.8 KB · Views: 24

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Are you saying you tried the formula below and it was too slow ? That is not what I am experiencing.

Excel Formula:
=UNIQUE(FILTER('source file'!$A$2:$F$5000,'source file'!$A$2:$A$5000=$C$2,""))
 
Upvote 1
Solution
Hi Alex,

Thank you for the solution it works, however found another issue in regards of the formula shared.

1. column D and Column F can be empty or with different data
2. column F can be empty or have different values

how can i modify the formula to unique filter based on Column A and Column B only however still generating unique list from column A to column F
 

Attachments

  • source file 2.png
    source file 2.png
    90.7 KB · Views: 9
Upvote 0
RESEND due to incorrect data

Hi Alex,

Thank you for the solution it works, however found another issue in regards of the formula shared.

1. column D and Column E can be empty or with different data
2. column F can be empty or have different values

how can i modify the formula to unique filter based on Column A and Column B only however still generating unique list from column A to column F
 

Attachments

  • source file 2.png
    source file 2.png
    90.7 KB · Views: 9
Upvote 0
But if you have different data in C to F for the same A B combination which data do you want to show in C to F
 
Upvote 0
Hi Alex,

have done the checks, cells in column C to F will either have data (same as other duplicate entry) or blank.
 
Upvote 0
Can you show me some sample data preferably as an XL2BB ?

XL2BB
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
found interim solution which is to update values on duplicate row column C to F based on VLOOKUP in source file prior running the formula in target file to ensure only have unique values in .
however this needs to be done separately every time a data rows is added.

cant seem to be able to install XLBB add ins into my PC, getting msg " this file type is not supported in protected view."
appreciate if i could share the data in other means. Thanks
 
Upvote 0
Try right clicking on the Add-In > Select Properties > if in the bottom right corner there is an Ublock check box tick that.
Then try the XL2BB again.

Also when you say the duplicate line is either the same or blank, when its blank are all the cells in C to F on the same row blank ?
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,168
Members
452,615
Latest member
bogeys2birdies

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