• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code vlookup column and paste value in specified headers

Laximikant Naik

New Member
I am new to VBA, I need a code to perform a certain task. I have uploaded a file that explains everything.
 

Attachments

  • Test case.xlsx
    15.8 KB · Views: 11
Lax,

In the "Master" sheet where does "Type" and "Temp" come from?
Also, "Dimension" in data sheet. and too, provide what the data in the "Master" sheet that meet your request.
 
Last edited:
Hi Charles,

Thanks for your response!

"Master" Sheet will comprise series of attribute headers which may or may not exist in "Delimited/data" sheet. U just have to concentrate on "delimited" and "data" sheets where vlook up matches of cells just paste in matching headers of "master sheet. I have attached Master sheet i need after the macro runs. just refer master sheet.
 

Attachments

  • Test case.xlsx
    15.8 KB · Views: 6
Lax,
Here's a copy that I think you want. If not Please correct to let use know what the "Master" should show.
 

Attachments

  • Test case (1)ch.xlsm
    12.8 KB · Views: 8
1. There are 4 Part numbers in this case. Normally it can be any number of Part numbers
2. Macro will always start from cell B2. Vlookup content of Cell B2 from "Delimited" sheet with data in A &
B column of "Data" sheet. In this case Vlookup "GRM" with A & B column of "Data" sheet, you will get "SMD" as a result. Paste this result (SMD) to Column header of Column B, that is "Mounting". Search Column header of B "Mounting" in "Master" sheet and Paste the result "SMD" in first cell of "Mounting" column in Master sheet.
3. Now in "Delimited" sheet move to next column C and repeat the vlookup activity. In this case vlook up 32
with column C & D of "Data" sheet and paste the result "32 Pins" by searching column header of C column in "Delimited" sheet "No of Pins" in Master sheet and paste it in first cell of that column.
4.Next move to D column and Vlook up "F" in "Delimited" sheet with E and F column of "Data" sheet and paste the result "1" in column header of D "Tolerance" by searching it in Master sheet by pasting it in first cell.

5.Now move to next part number and repeat the same steps as above. Like wise do it for all part numbers

6.if any charatcer in "delimited" columns does not match with their lookup table , highlight that part number in "Delimited" sheet

7. This macro should be dynamic in range. Part numbers can be multiple characters. Delimiting can be into multiple columns but in same sequence as in this case. Similarly headers can be anything. If header matches with any header in Master sheet, then only paste data. Otherwise ignore

refer to attached sheet for example explained above
 

Attachments

  • Mac.xlsm
    13.6 KB · Views: 8
Lax,
Sorry for the delay. I've been lookin at your file trying to determine
the reason for code.
You have 3 sheets. You can actually narrow that to 2 sheets. "Delimited" and "Master". I reformatted the "Delimited" sheet.
But, for the project I can not see why you are doing this. There must be something I'm missing as to your logic.
 

Attachments

  • Test case (2)ch.xlsm
    11.4 KB · Views: 13
Hello Charles,

Thanks for your reply.

Actually solution provided by you also will be fine. If you can provide VBA macro code for performing the activity of copying data as per the delimited char. Also just take care that code should be dynamic. As delimited data can be anything. But the column pattern will be same
 
Lax,
Sorry for the delay again.
I'm having a hard time for a solution.
Perhaps another forum Member can take a look at you file
to determine if they can come up with an answer. If not you may need to reformat your file.
 
Hi,
Here's a file you can test. Just click the "Run" button. You will need to clear the Master sheet when you test again.
 

Attachments

  • MoveDataTest.xlsm
    27 KB · Views: 18
Back
Top