How to get values related to another from multiple sheets in excel - excel

I have an excel sheet containing employee details
EmployeeID | Name
1 | Name1
2 | Name2
and another sheet which has the address details
Name | Address
Name1 | Address1
Name2 | Address2
Is there a way I can get the address details from the second sheet and put it in the first. The output that I need is
EmployeeID | Name | Address
1 | Name1 | Address1
2 | Name2 | Address2

Example:
Sheet1
EmpID Name Addresss
1 1 El Chapo =VLOOKUP(B2,Sheet2!$A$2:$B$4,2, FALSE) // "Mazatlan, Sinoloa"
2 2 El Mencho =VLOOKUP(B3,Sheet2!$A$2:$B$4,2, FALSE) // "Tierra Caliente, Michoacan"
3 3 El Ondeado =VLOOKUP(B4,Sheet2!$A$2:$B$4,2, FALSE) // "Culiacan, Sinoloa"
Sheet2
Name Addresss
1 El Chapo Mazatlan, Sinoloa
2 El Mencho Tierra Caliente, Michoacan
3 El Ondeado Culiacan, Sinoloa
Add the VLOOkUP formula into the address column of Sheet1

Related

Formula for count of distinct values, multiple conditions, one of which = or <> all repeating values

Excel formula (I know this may work with a pivot table, but wanting a formula) to count distinct values. If this is my table in Excel:
Region | Name | Criteria
------ | ------ | ------
1 | Jill | A
1 | Jill | A
1 | John | B
1 | John | A
2 | Jane | B
2 | Jane | B
2 | Bill | A
2 | Bill | B
3 | Mary | B
3 | Mary | B
3 | Gary | A
3 | Gary | A
In this example, I have the following formual to calculate the distinct values within each region =SUM(--(FREQUENCY(IF((Table1[Region]=A2)*(Table1[Name]<>""),MATCH(Table1[Name],Table1[Name],0)),ROW(Table1[Name])-ROW(Table!B2)+1)>0)) which results in 2 each (Region 1=Jill & John; 2=Jane & Bill, 3=Mary & Gary, each distinct name counted once).
I have an addition formula to calculate how many distinct values with criteria where there is at least 1 "B" for each distinct name within each region, by adding *(Table1[Category]="B") after <>"") ... in this example, it would return Region 1=1, Region 2=2, 3=1, because Jill nor Gary do not have "B" - all others have at least one "B".
Now I'm getting stuck on my last formula, where I want to count how many distinct values within each Region have ALL B's in all their occurrences. The outcome should be Region 1=0 (Jill has no B's and John has a B, but also has an A), Region 2=1 (Jane appears twice, counts as 1 distinct value, and both occurrences are B, Bill has a B in one of his), and 3=1 (Mary has all Bs).
It's too complex for a formula-only task, but feasible.
The following array formula does the job. Although you did not specify it, but I suppose that if "Mary" has an A in another region, this should not cancel her counting in region 3, so long as all records with name "Mary" in region 3 have a "B". In other words, names can repeat in different regions but should not interfere across regions (which made the formula even longer. I added a test case for this, Mary in region 4 with an A did not interfere with Mary in region 3).
=SUM(IF((Table1[Region]=Table1[#Region])*(0=COUNTIFS(Table1[Region],Table1[#Region],
Table1[Name],Table1[Name],Table1[Criteria],"<>B")), 1/COUNTIFS(Table1[Name],Table1[Name],
Table1[Criteria],"B",Table1[Region],Table1[#Region]), 0))
Enter it then press CtrlShiftEnter. then copy/paste down the column.

Excel - Finding Cells with Top Values

| Company 1 | Company 2
Item 1 | 7 | 0
Item 2 | 1 | 0
Item 3 | 2 | 8
Item 4 | 0 | 3
Item 5 | 0 | 1
So I need to grab the cell/row number for the top 3 ordered values in a given column so for Company 1 you'd get B2, B4, B3 and for Company 2 you'd get C4, C5, C6.
To return the row number use this formula:
=MATCH(LARGE(B$2:B$6,ROW(1:1)),B:B,0)

excel, combine multiple columns into one row

Am new to this so any help would be greatly appreciated.
I have an excel spread sheet with multiple columns, and I want to combine several columns into one column but maintain the same row. i.e.
from:
Name Address Phone1 Phone2 Phone3
Joe box 5 123-456-7890 Null 312-778-2564
Sue 3 w 2nd ST. 345-789-3214 156-879-5461 278-444-5687
Mike box 12 Null 666-879-4518 777-548-9851
To:
name address Phone
Joe box 5 123-456-7890
Null
312-778-2564
Sue 3 w 2nd ST. 345-789-3214
156-879-5461
278-444-5687
Mike box 12 Null
666-879-4518
777-548-9851
Say your information is in columns A and B so:
A | B
1 | z
2 | y
3 | x
To combine A and B in column C you would write the following in cell C1 and copy it down
=A1&B1
The final result would be
A | B | C
1 | z | 1z
2 | y | 2y
3 | x | 3x

Move data onto blank row below Excel from multiple columns with VBA macro

I currently have data in the following format:
Name 1 | Email 1 | ID 1 | Address 1 Street | Address 1 Suburb | Address 1 City | Address 2 Street | Address 2 Suburb | Address 2 City | Address 3 Street | Address 3 Suburb | Address 3 City
<NEW LINE>
Name 2 | Email 2 | ID 2 | Address 1 Street | Address 1 Suburb | Address 1 City | Address 2 Street | Address 2 Suburb | Address 2 City
etc.
And I need it to look like the following:
Name 1 | Email 1 | ID 1 | Address 1 Street | Address 1 Suburb | Address 1 City
<NEW LINE>
Name 1 | Email 1 | ID 1 | Address 2 Street | Address 2 Suburb | Address 2 City
<NEW LINE>
Name 1 | Email 1 | ID 1 | Address 3 Street | Address 3 Suburb | Address 3 City
<NEW LINE>
Name 2 | Email 2 | ID 2 | Address 1 Street | Address 1 Suburb | Address 1 City
<NEW LINE>
Name 2 | Email 2 | ID 2 | Address 2 Street | Address 2 Suburb | Address 2 City
etc.
What I have so far in my spreadsheet is in column A is a COUNTA formula to work out the number of rows we need to insert below each row to allow for the data to be duplicated which is calculating fine. From this I have used the following code to insert these number of lines which is also working fine.
Sub ProcessAddressLabels()
For N = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(N, 1) <> "" And Cells(N, 1) <> 1 Then
Rows(N + 1 & ":" & N + Cells(N, 1) - 1).Insert
NumValues = Cells(N, 1)
End If
Next N
End Sub
What I am not sure from here is how to copy each set of 3 cells from the end and place it along with the duplicated user data onto the lines below!
Any help is much appreciated and I hope I explained this simply enough!
Give this a try:
Sub Test()
Dim rw As Range, n As Long, i As Long, x As Long
Set rw = ActiveSheet.Rows(1) 'starting row
Do While rw.Cells(1).Value <> ""
'how many sets of addresses to move?
x = Application.Ceiling((Application.CountA(rw) - 6) / 3, 1)
If x > 0 Then
'insert required rows
rw.Offset(1, 0).Resize(x).Insert
For i = 1 To x
'copy common cells
rw.Cells(1).Resize(1, 3).Copy rw.Cells(1).Offset(i, 0)
'cut each address block
rw.Cells(7 + ((i - 1) * 3)).Resize(1, 3).Cut rw.Cells(1).Offset(i, 3)
Next i
End If
'move to next "new" row
Set rw = rw.Offset(1 + x, 0)
Loop
End Sub
I cannot say I fully understood all your needs, however
would something like this help:
Dim sht As Worksheet
Set sht = ActiveSheet
' copy the range C1:F1 to the start of the third row.
sht.range("C1:F1").Copy Destination:=Worksheets("Sheet1").range("A3")

Excel: take ID from one list to another list

I want to combine two lists with the ID from one of them but haven't found a solution for this. These are my two lists:
List 1:
NAME | CAR
john | audi
karen | opel
List 2:
CAR | ID
audi | 1
opel | 2
what I want is the ID to get from list 2 to list 1, so that my list 1 will look like:
NAME | CAR | ID
john | audi | 1
and so on…
How can I do this in Excel?
Use procv function
Exemple
=VLOOKUP(CAR;LIST2;2;0)
where CAR is cell with name of car and LIST2 is range of cell with list 2.

Resources