VBA Excel Search every cell value from one column in another column and return output in desire columns

paneliyadhruv

New Member
Joined
May 21, 2018
Messages
36
Dear All,

Kindly help me to solve below mention problem.
In column A- master code from A2 to A
In column B- master code of fruit from B2 to B
In column C - list of fruits based on user entry

Procedure - Search column B name in column C, if name of that fruit present in column C then copy name in column E2 and master code of that fruit in column F. So on for searching of all cells of column B in column C and return values in E and F.

Master CodeMaster ListList based on User entryOutput required with codecode
1applegrapefruitapple1
1apricotlemonapricot1
2avocadoblueberryblueberry4
3bananaboysenberryboysenberry5
3blackberrygrapefruit8
4blackcurrantapplelemon8
4blueberryapricotmelon9
5boysenberrynectarine9
6cherrymelonorange9
7coconutnectarinepomegranate14
7figorangequince14
8grapepomegranate
8grapefruitquince
8kiwifruit
8lemon
8lime
8lychee
8mandarin
9mango
9melon
9nectarine
9orange
10papaya
11passion fruit
11peach
12pear
13pineapple
14plum
14pomegranate
14quince
15raspberry
16strawberry
17watermelon

<tbody>
</tbody>
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
How about
Code:
Sub paneliyadhruv()
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      .CompareMode = 1
      For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
         If Not Cl.Value = "" Then .item(Cl.Value) = Empty
      Next Cl
      For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
         If .Exists(Cl.Value) Then .item(Cl.Value) = Cl.Offset(, -1).Value
      Next Cl
      Range("E2").Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .Items))
   End With
End Sub
 
Upvote 0
Cross posted https://chandoo.org/forum/threads/s...mn-and-return-output-in-desire-columns.40936/

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

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