Search and paste value from other sheet (combination of vlookup,hlookup,index)

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

ino sheet1 I have table:


Into sheet2 I have other table:



How to write a function, that will be automaticly taken value from sheet1 and put into col H - Target, to sheet2?
 

wideboydixon

Well-known Member
Joined
Jun 2, 2016
Messages
3,401
Here's what I have in Sheet 1:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>P</th><th>Q</th><th>R</th><th>S</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;;">Sales Level 1</td><td style="font-weight: bold;;">Sales Level 2</td><td style="font-weight: bold;;">COL3</td><td style="font-weight: bold;;">Q1</td><td style="font-weight: bold;;">Q2</td><td style="font-weight: bold;;">Q3</td><td style="font-weight: bold;;">Q4</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">A</td><td style="text-align: right;;">1</td><td style="text-align: right;;">16</td><td style="text-align: right;;">31</td><td style="text-align: right;;">46</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">D</td><td style="text-align: right;;">2</td><td style="text-align: right;;">17</td><td style="text-align: right;;">32</td><td style="text-align: right;;">47</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">B</td><td style="text-align: right;;">3</td><td style="text-align: right;;">18</td><td style="text-align: right;;">33</td><td style="text-align: right;;">48</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">C</td><td style="text-align: right;;">4</td><td style="text-align: right;;">19</td><td style="text-align: right;;">34</td><td style="text-align: right;;">49</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">E</td><td style="text-align: right;;">5</td><td style="text-align: right;;">20</td><td style="text-align: right;;">35</td><td style="text-align: right;;">50</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_GERMANY</td><td style=";">A</td><td style="text-align: right;;">6</td><td style="text-align: right;;">21</td><td style="text-align: right;;">36</td><td style="text-align: right;;">51</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_GERMANY</td><td style=";">D</td><td style="text-align: right;;">7</td><td style="text-align: right;;">22</td><td style="text-align: right;;">37</td><td style="text-align: right;;">52</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_GERMANY</td><td style=";">B</td><td style="text-align: right;;">8</td><td style="text-align: right;;">23</td><td style="text-align: right;;">38</td><td style="text-align: right;;">53</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_GERMANY</td><td style=";">C</td><td style="text-align: right;;">9</td><td style="text-align: right;;">24</td><td style="text-align: right;;">39</td><td style="text-align: right;;">54</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_GERMANY</td><td style=";">E</td><td style="text-align: right;;">10</td><td style="text-align: right;;">25</td><td style="text-align: right;;">40</td><td style="text-align: right;;">55</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_POL</td><td style=";">A</td><td style="text-align: right;;">11</td><td style="text-align: right;;">26</td><td style="text-align: right;;">41</td><td style="text-align: right;;">56</td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_POL</td><td style=";">D</td><td style="text-align: right;;">12</td><td style="text-align: right;;">27</td><td style="text-align: right;;">42</td><td style="text-align: right;;">57</td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_POL</td><td style=";">B</td><td style="text-align: right;;">13</td><td style="text-align: right;;">28</td><td style="text-align: right;;">43</td><td style="text-align: right;;">58</td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_POL</td><td style=";">C</td><td style="text-align: right;;">14</td><td style="text-align: right;;">29</td><td style="text-align: right;;">44</td><td style="text-align: right;;">59</td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR_POL</td><td style=";">E</td><td style="text-align: right;;">15</td><td style="text-align: right;;">30</td><td style="text-align: right;;">45</td><td style="text-align: right;;">60</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br />

And here's my Sheet 2:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;;">Year</td><td style="font-weight: bold;;">Time</td><td style="font-weight: bold;;">Quarter</td><td style="font-weight: bold;;">Theatre</td><td style="font-weight: bold;;">Sales Level 1</td><td style="font-weight: bold;;">Sales Level 2</td><td style="font-weight: bold;;">Segment</td><td style="font-weight: bold;;">Target</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">2016</td><td style=";">2016Q1</td><td style=";">Q1</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">A</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">2016</td><td style=";">2016Q2</td><td style=";">Q2</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">A</td><td style="text-align: right;;">16</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">2016</td><td style=";">2016Q3</td><td style=";">Q3</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">A</td><td style="text-align: right;;">31</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">2016</td><td style=";">2016Q4</td><td style=";">Q4</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">A</td><td style="text-align: right;;">46</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">2016</td><td style=";">2016Q1</td><td style=";">Q1</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">B</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">2016</td><td style=";">2016Q2</td><td style=";">Q2</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">B</td><td style="text-align: right;;">18</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;">2016</td><td style=";">2016Q3</td><td style=";">Q3</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">B</td><td style="text-align: right;;">33</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;">2016</td><td style=";">2016Q4</td><td style=";">Q4</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">B</td><td style="text-align: right;;">48</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: right;;">2016</td><td style=";">2016Q1</td><td style=";">Q1</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">C</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;;">2016</td><td style=";">2016Q2</td><td style=";">Q2</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">C</td><td style="text-align: right;;">19</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: right;;">2016</td><td style=";">2016Q3</td><td style=";">Q3</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">C</td><td style="text-align: right;;">34</td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: right;;">2016</td><td style=";">2016Q4</td><td style=";">Q4</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">C</td><td style="text-align: right;;">49</td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: right;;">2016</td><td style=";">2016Q1</td><td style=";">Q1</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">D</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style="text-align: right;;">2016</td><td style=";">2016Q2</td><td style=";">Q2</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">D</td><td style="text-align: right;;">17</td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style="text-align: right;;">2016</td><td style=";">2016Q3</td><td style=";">Q3</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">D</td><td style="text-align: right;;">32</td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style="text-align: right;;">2016</td><td style=";">2016Q4</td><td style=";">Q4</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">D</td><td style="text-align: right;;">47</td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style="text-align: right;;">2016</td><td style=";">2016Q1</td><td style=";">Q1</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">E</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: #161120;text-align: center;">19</td><td style="text-align: right;;">2016</td><td style=";">2016Q2</td><td style=";">Q2</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">E</td><td style="text-align: right;;">20</td></tr><tr ><td style="color: #161120;text-align: center;">20</td><td style="text-align: right;;">2016</td><td style=";">2016Q3</td><td style=";">Q3</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">E</td><td style="text-align: right;;">35</td></tr><tr ><td style="color: #161120;text-align: center;">21</td><td style="text-align: right;;">2016</td><td style=";">2016Q4</td><td style=";">Q4</td><td style=";">CENTRAL</td><td style=";">EMEAR-REGION</td><td style=";">EMEAR-CENTRAL</td><td style=";">E</td><td style="text-align: right;;">50</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet2</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">H2</th><td style="text-align:left">{=INDEX(<font color="Blue">Sheet1!$P:$S,MATCH(<font color="Red">1,(<font color="Green">Sheet1!A:A=$E2</font>)*(<font color="Green">Sheet1!B:B=$F2</font>)*(<font color="Green">Sheet1!C:C=$G2</font>),0</font>),MATCH(<font color="Red">$C2,Sheet1!$P$1:$S$1,0</font>)</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

Hope that's somewhere near what you're after.

WBD
 

SKM0005

New Member
Joined
Aug 12, 2016
Messages
2
Hi... If anyone needs the solution...

One way is to:
Make index columns as Sheet1:B+C and Sheet2:F+G, to use as the key fields
Use a formula in sheet2:H with if loops on sheet2:C value to check as “Q1”, “Q2”, “Q3” or “Q4”; to “VLOOKUP” on the above index Sheet1:P,Q,R,S value respectively
:)
 

wideboydixon

Well-known Member
Joined
Jun 2, 2016
Messages
3,401
thank you wideboydixon! just checked and it's working fine.
Good to know. Note that the performance won't be fantastic as it's processing all the rows in the sheet. If you know how many rows you have in Sheet1, you could optimize a little bit.

WBD
 

Forestq

Active Member
Joined
May 9, 2010
Messages
482
working slowly, but working, number of rows is always the same. so I will change it, but one time per quater it can working like this ;)
 

Forum statistics

Threads
1,081,730
Messages
5,360,934
Members
400,602
Latest member
newaqua

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top