Set the value from another sheet. With a test of condition. Excel - powerpivot

I have a table with two sheets. On the first (1) the name is written, on the second (2) Imin and numerical meaning are written, the same name can be written several times. There are also names that are not present on the sheet (1).
Sheet 1.
A
Column A
Column B
Vova--
Ben
Sheet 2.
Column A
Column B
Ben +
2
Timmy
1
Ben T
4
Vova
6
How to put in the first sheet the sum of the values from the sheet (2)
I tried:
=IF(ColA2 = $Sheet2 ColA2; $Sheet2 ColB2)
=VLOOKUP(A1;$Sheet2.B2:B4;2)
=SUMIF($'Sheet2'A1:A4;A1;$'Sheet2'ColB1:ColB4)
Not work
Does not summarize the value
Looking for accurate coincidences
Names can end in different ways ...
Ben = Ben T
Required:
Column A
Column B
Vova--
6
Ben
3
Need help please.

I found an answer. I need to use LEFTB
=SUMIF($'Sheet2'A1:A4;LEFTB(A1;4)&"*";$'Sheet2'ColB1:ColB4)
or
=SUMPRODUCT((LEFTB($Sheet2!$A$1:$A$4;3)=A2)*$Sheet2!B2:B5)

Related

(VBA) Extract and copy and paste column values for specified date range for corresponding row values

I've been stuck on this for a while now. What I need is the title - what I have is:
Sheet 1:
1 billion mostly unnecessary columns.
Column D: Values I need Column F: Column M:
Revenue Names Date
12 John 1/24/2016 2:40:02 AM
15 Sarah 3/2/2016 4:35:17 PM
14 Sarah 7/17/2016 1:50:10 PM
20 Matt 8/20/2012 4:16:12 AM
10 John 11/19/2015 5:04:05 AM
etc. etc.
Current Sheet 2: Pivot Table*
Row Label:
Sarah
Matt
John
etc.
Desired Sheet 2 Pivot Table+*
Row Label: Column __:
Revenue
Sarah 29
Matt 0 *(note: see below, but = 0 because Matts value corresponded to date 2012)
John 22
etc.
The important thing about Sheet 2 is that I would like to tell VBA to find the nearest emptiest column within the sheet, and input the values from Column D from S1 (and sum for duplicates) but only sum and extract values that range from today's date to 11 months prior. Currently I made a module to automatically create a pivot table for the next sheet, but I have wanted to add the above for a while, just stuck.
I'm also assuming I won't have to specify sum if I tell VBA to extract data for corresponding row label names? And I was thinking about putting a Begin Date and End Date cells on Sheet 2 to refer to, or using the TODAY() function somehow for the date, but not sure how to specify to extract and sum values for the date range from today to 11 months prior.
Edit: *Please note this is a watered down version of my current situation, everything is bigger so to avoid confusion, pivots are necessary, but I choose to dilute it for the sake of this issue.
Do you really need a pivot table?
If you dont, just create a new sheet with all the names, set a cell for the starting date you want to consider and do =sumifs
For example
On Sheet2 B1 you put 1/24/2016.
Then on A2 you insert the name (Sarah, for example)
On B2 you put the formula
=Sumifs(Sheet1!D:D,Sheet1!F:F,A2,Sheet1!M:M,">"&B$1)
After that just make a list of name and drag the formula beside every name.
*My excel is in portuguese so maybe the formula needs some other ajustments to work.

Use of Index and Match function with Count/Counta/Countif to count the results on a 3rd wookbok

I have great success in guidance from the experts on Stack. I need guidance once more. :)
I have workbook 1 that has a copy of names on column A and email addresses on column B. Workbook 2 that has copy of names on A and email addresses on column B and data that I need copied on Column c on workbook 2.
I have a workbook 3 in which I would like to use to build a table with matched and counted from the formula I need. Below I will show.
workbook 1 pic:
Workbook 2 pic:
Workbook 3 pic:
Ultimately, I wanted the index,matched and counted total to show up on the basic table shown on workbook 3. As you can see there are 4 email addresses that match between work book 1 and workbook 2, but there are also 4 email addresses that do not match. after the matching and unmatching is found, i want the formula to give me the count of the matched and unmatched from column c in workbook 2.
so if you just use your eyes and count, you will see that rows 2 through 4 these email addresses matched between work book 1 and work book 2. that would give me a total of 2 drinks expenses and 2 food expenses from the matching found, but also give me 2 tickets expenses and 2 parking expenses from the unmatched found.
For the Matched:
=SUMPRODUCT((COUNTIFS('Sheet1'!A:A,'Sheet2'!$A$2:$A$100,'Sheet1'!B:B,'Sheet2'!$B$2:$B$100)>0)*('Sheet2'!$C$2:$C$100=$B3))
For the unMatched
=SUMPRODUCT((COUNTIFS('Sheet1'!A:A,'Sheet2'!$A$2:$A$100,'Sheet1'!B:B,'Sheet2'!$B$2:$B$100)=0)*('Sheet2'!$C$2:$C$100=$B7))
These are untested as I did not want to retype that much data, but in thoery should work.

Excel vba code to copy names found in multiple worksheets and count how many times they appear

I need some help writing some VBA code.
Basically I have one spreadsheet with 4 worksheets (CLIENT1, CLIENT2, CLIENT3, CLIENT4)
Each worksheet contains a column called CONTACT.
This CONTACT column contains a person name
The CONTACT column can be in a different position in each worksheet ie the CONTACT column in CLIENT1 is in Column D whereas it appears in column E in CLIENT2
I would like some help writing some code that will create a new Worksheet called SUMMARY.
The SUMMARY worksheet would contain in Column A a list of all the names found in the CONTACT column and in Column B it would count the number of times that persons name was found.
So the SUMMARY worksheet would end up looking something like this.
A B
1 John Smith 4
2 Brad Black 2
3 Gary Soth 1
4 Bob Brown 6
5 Sam Drow 2
Hope this makes sense and thanks for your help
Andy
Note : I am just playing with Excel and not using VBA but think you can achieve it without using VBA also.
You can use COUNTIF and solve your problem.
I will show you step by step. I cant attach excel here so adding images. If you wish to have excel which i prepared then just give me your email, I will send it.
This is summary which I got by using the formula (you can see that highlighted :
Client Name column can get value from the sheet where you can combine all your unique client names and use that as base.
Check Client1, 2, 3 & 4 sheets.
Hope this may help you.
Just found that in Excel you can use the Remove Duplicates function to remove all unwanted names. I can then use the count function across all 4 worksheets to get the required information.
Thanks
Andy

Using VBA to create a grid from 3 spreadsheets with the row, column, and values

I have three excel spreadsheets. The first has the values that are to be assigned to a new excel spreadsheet. The second has the column that the data belongs in. The third has the row that the data belongs in.
It looks something like this:
Data Value:
1 5 7 9
2 2 6 8
Column Number:
1 2 3 1
2 3 1 2
Row Number:
1 2 3 2
4 4 3 1
How can I combine all of this information to create a single spreadsheet that contains the values in a format like this:
Column
1 2 3
Row
1 1 8 0
2 9 5 0
3 6 0 7
4 0 2 2
I have tried to do it by using loops in vba, but I am a beginner and I am having some difficulty.
I know that I need to use a loop that checks the row and column that the data is supposed to be in against the row and column for each iteration. I am just not sure how to go about doing that.
Assuming these are different sheets in the same workbook (if not - create a new workbook and copy the sheets over). I assume that on each sheet, the same range of cells is used (for example A1:D2 in all 3 cases with the values on the first sheet, the column numbers in the second and the row numbers in the third). You can dispense with VBA entirely at the expense of using some complicate formulas (inspired by this excellent article: http://exceluser.com/blog/1043/how-to-create-two-dimensional-lookups-in-excel-formulas.html )
Step 1. Add a fourth sheet and in A1 add the formula
=CONCATENATE(Sheet3!A1,"_",Sheet2!A1)
and copy it over the appropriate range (e.g. A1:D2). This will give you things like 2_1 which tell you that the corresponding entry in sheet 1 belongs in row 2 column 1. Name this range "location" (formula tab - define names option)
Step 2 - Decide where you want to hold the data (I'm assuming it is in sheet 4 for simplicity) And add the row numbers (1-4) and the column numbers (1-3) as labels. In my case the row labels are in A5:A8 and the column labels in B4:C4 (see the screenshot below). Then in the upper left corner of the values to be filled in (B5 in my case) enter the following formula (suitably adjusted to match your ranges):
=IFERROR(INDIRECT(ADDRESS(SUMPRODUCT(ROW(location)*(location = CONCATENATE($A5, "_",B$4))),SUMPRODUCT(COLUMN(location)*(location = CONCATENATE($A5, "_",B$4))),,,"Sheet1")),0)
and copy it over the intended range. Be careful with the dollar signs - this formula mixes row absolute and column absolute references in an essential way. Somewhat oddly, it actually works:

How to compare a list of rows to another list of rows in Excel?

I am trying to figure out if there are any differences between a list of data with another. In order for a row of data to "match" with another row, the row must have the same values in their corresponding column. The rows themselves do not have to be in any particular order. In particular, I am dealing with a parts list, where there are part numbers, descriptions, etc. I am trying to figure out if any rows of data are different from rows of data from another list.
I found Compare two sheets using arrays, which may have the answer to my problem, but I am having trouble figuring out how to adapt to my code due to inexperience in Visual Basic.
I was able to get it to work for a single column of data, comparing one column of data from one sheet to another, but cannot get it to compare entire rows of data.
Here is an example of I want this to work:
Sheet 1 Sheet 2
Column 1 Column 2 Column 1 Column 2
Row 1 22a 33 11 11
Row 2 22a 33a 22a 33
Row 3 55 22b 55 23b
The code in the link will tell you what is not in sheet 1 but in sheet 2 and vice versa. In this example, I would like the code to tell me Sheet 1 Row 2 and Sheet 1 Row 3 are not in Sheet 2, and Sheet 2 Row 1 and Sheet 2 Row 3 are not in Sheet 1 (Sheet 1 Row 1 and Sheet 2 Row 2 match).
If that is ok by you, you can do it without VBA using the following formula:
={IF(IFERROR(MATCH(A1&"|"&B1;Sheet7!$A$1:$A$3&"|"&Sheet7!$B$1:$B$3;0);-1)=-1;"Unique";"")}
Assuming that each of your tables start in A1 (so that the tables with three entries span A1:B3), and entering this formula into C1 (and copying it down), press CTRL+SHIFT+ENTER when entering the formula to create an array formula, this will show the word "Unique" in column C if the pair in that row on that sheet is not in any of the row-pairs on sheet 2.
You can then use conditional formatting to highlight unique rows, filter on the tables to include only unique rows, or some other way of doing what you need.
NOTE 1: I have entered my numbers in Sheet6 and Sheet7 instead of 1 and 2. The formula written above goes into Sheet6.
NOTE 2: My language use ; instead of , as function separator, so if yours use , you need to change that.
NOTE 3: You will need to expand the ranges Sheet7!$A$1:$A$3 and Sheet7!$B$1:$B$3 if your set grows (this will happen automatically if new rows are inserted in between the old ones). The best is still probably to create named ranges for each of the 4 columns, exchange the references with those, and manage the named ranges instead of the formulas.
NOTE 4: If your data set contains the character "|", you need to change that as well, to match some character that you for sure do not have there.
Alternatively you could in column C on each cheet enter (assuming first entry in C1)
=A1&"|"&B1"
and copy this down, then run the solution from your copied example using that C column instead of on A1 and B1.