Lookup or better method.

nparsons75

Well-known Member
Joined
Sep 23, 2013
Messages
1,256
Office Version
  1. 2016
Hi,

I have 2 worksheets, WS1 and WS2.

In WS1 I have a table and in Column A is a reference number (unique). Currently 1 to 15.

In WS2 I also have a table with multiple rows. In each row is a reference to a unique ref number in WS1.

For example, Ref 1 may have multiple rows in WS2 that refer to the unique ref number 1. (Column B, WS2)

In Column G of WS2 there is a value between 0 and 100.

In Column F of WS1 there is also a value between 0 and 100.

This is what I need to happen.

I need WS1 (column A) to look at WS2 (Column B) and find all the rows that refer to the same unique ref number. As an example there may be 3 rows that contain ref number 1.

Then, I need the total of all the values in Column B of WS2 to be added together and divided by the number of rows that the unique ref is found in, (in this case 3). The result will then be displayed in Column F of worksheet 1.

Hope that makes some sense....Thank you.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this one or share your data in table format!

Code:
=SUMIF($B$1:$B$17,'WS1'!A1)/COUNTIF($B$1:$B$17,'WS1'!A1)

[TABLE="width: 384"]
<colgroup><col width="64" span="6" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="class: xl64, width: 64"] 1.00 [/TD]
[TD="width: 64, align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="class: xl64"] 2.00 [/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="class: xl64"] 3.00 [/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="class: xl64, align: center"]#DIV/0![/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="class: xl64"] 5.00 [/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]9[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]11[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]16[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]17[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]#DIV/0![/TD]
[TD="align: right"]18



[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Thanks Muhammad, I managed to get a fix for this, thanks for your help.

I used: =IFERROR(SUMIF('WS2'!$B$19:$B$26,A18,'WS2'!$G$19:$G$26)/COUNTIF('WS2'!$B$19:$B$26,A18),0)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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