In Excel, how do I copy a column when the column number is the result of a function and that result varies? - excel

I have some data where the column order is unknown, but the names of the columns are the same. For example:
Sale | Date | User
| |
5 | 1/2/2020 | A
Or it could come as:
Date | User | Sale
1/2/2020 | A | 5
I am able to use the Match formula to get the column number.
Let's say that I use my formula and find that in this particular data set, Date is column A, User is column B, and Sale is Column C.
What formula would I use to copy and paste the column into a new sheet?

Related

How if capture particular cell value

I have entered a date in Column A and column B.
Column A | Column B | Column C
---------------------------------------
23/9/2019 | 19/9/2019. |
Now i am trying to get date in a column c which is greater. Which formula should I use?
Use the MAX() worksheet function. It will give you the greater (that is, the larger or most recent) of the two values.
Just make sure the values are true Excel dates and not text values.

Aligning duplicates in Excel

I have 3 columns in Excel. The data in first column are complete dates from given year in ascending order. In second column are also dates but in between these dates there can be a missing day. So if i place these dates next to each other they do no line up. And in third column there is some date that corresponds to the date in 2nd column. Now what i would like to do is to align those dates, and where there is no date in first column the row is empty.
I have already put some code together for excel to lign up the data, but i dont know how to align the dates together with the values in third column(C column).
Here is my code:
=IF(ISNA(MATCH(A1;C:C;0));"";INDEX(C:C;MATCH(A1;C:C;0)))
Here is a visualization(the data in column A is all the dates in a given year. The data in column B and C must be moved together):
| A | B | C |
|1.1.2018 |3.1.2018 |12345 |
|2.1.2018 |14.1.2018 |54321 |
|3.1.2018 |2.2.2018 |56789 |
|4.1.2018 |2.1.2018 |11111 |
Desired output:
| A | B | C |
|1.1.2018 | | |
|2.1.2018 |2.1.2018 |11111 |
|3.1.2018 |3.1.2018 |12345 |
|4.1.2018 | | |
Based on your sample data this formula will search column B for the first instance of the date that is in column A and return the value from column C on that row.
In cell D1 and dragged down:
=IFERROR(INDEX($C:$C,MATCH($A1,$B:$B,0)),"")
MATCH($A1,$B:$B,0) will return the row number that the date appears in in column B.
INDEX($C:C$,....) will return the value from column C based on the row number returned by the MATCH function.
If nothing is found then an #N/A error occurs which is dealt with by the IFERROR(.....,"") function.

How do I add information to a neighbouring cell if there is specific text in an existing cell?

I'm working with 311 datasets. I have monthly spreadsheets for a specific municipality with over 10,000 entries per sheet.
The columns in the datasheet provide details such as call description, time of call, date of call and the City Ward the call originated from.
Problem is that the spreadsheets only give the Ward number, i.e.:
creation_date | ward | call_description | call_type
01-Jan-15 | Ward 4 | Calendar to be Mailed | Solid Waste Collection
I have a separate spreadsheet that assigns shape coordinates for the respective ward:
OBJECTID | DESCRIPTIO | WARD_NUM | WARDNUMTEX | SHAPE_Length | SHAPE_Area
4 | XXXXX |4 | Ward 4 | 19871.78596 | 16418739.66
What I want to do is create a formula that when it sees Ward 4 in the one column, the SHAPE_Length and SHAPE_Area are assigned in the corresponding cell in the next column.
This is a job for vlookup().
Assuming that your tab with the shape coordinates is called wardinfo and that it starts in cell A1. Also assuming that your datasheets data starts in A1, meaning the ward number is in column B, your vlookup() to get the Shape_Length will be:
=vlookup(B1, wardinfo!C:F, 3, false)
And to get the Shape_Area:
=vlookup(B1, wardinfo!C:F, 4, false)
Just stick those in a new column on the same row and then copy them down.
You can use a VLOOKUP formula ( https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1 ), something like
=VLOOKUP(B2,Sheet2!D:F,2,FALSE)
Where B2 is the cell in the ward column your looking up, D:F is the range of columns you're using in the other sheet as a database (D is the column in the other sheet that has the Ward 4 index string, the rest of the columns you need should be to the right of that), and 2 is the column number that has the value you want to use as the result of the lookup (in that example, D is column 1, E would be column 2, probably SHAPE_Length and F would be column 3, probably SHAPE_Area).
You would put the formula a second time specifying column 3 for the second piece of info. The formula would go in the cell where you want the answer.

Increment count in column based on value in column

I've 2 columns A and B. A contains names and B contains the count of those names till that record as shown below.
-----------------------------------
| A | B |
-----------------------------------
1 | Fruits | 1 |
2 | Flowers | 1 |
3 | Fruits | 2 |
So, want to have a formula for this. Expecting an array formula. Even if an array formula is not possible, a general formula
Attached a spreadsheet so that it can be explained better.
https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit#gid=1997586177
You do not need an array formula, and I would avoid them when possible. You can accomplish your task with
=COUNTIF(A$1:A1,A1)
Where A1 if the first value in the column of values you want to count. The $ allows you to anchor the top of your COUNTIF range while leaving the bottom dynamic.
In a google spreadsheet you may want to try:
=ArrayFormula(iferror(SORT(ROW(A1:A),SORT(ROW(A1:A),A1:A,1),1)-MATCH(A1:A,SORT(A1:A),0)-ROW()+2))
Example sheet

Excel multi column lookup

I am unsure how to Google this one. I have a table that looks like the below
Last Name | First Name | Team A | Team B | Team C
Smith | John | X | |
Doe | Jane | | X |
This would be the main sheet. The names in this sheet are divided into other sheet depending on what department they are in. Those sheets are setup in the same formats with the same columns. If the people in the main sheet are marked with an X in one of the columns I would like that same column marked in marked in the department sheets.
Your best bet might be to create a hidden column A where the value is a combination of column B and column C on all of your tabs. You could then use the standard VLOOKUP wrapped in an IFERROR clause.
For example,
=IFERROR(VLOOKUP(A1,Sheet1!A:F,3,False),"")
The IFERROR handles the instance that you may have a name on a sub tab not on the main tab. It returns blank instead of #N/A. The VLOOKUP is checking the value in A1 to what is in A1 on your main tab. A1 would be the combination of First and Last. The VLOOKUP would need to be in each of your team columns shifting the column returned number in each VLOOKUP.

Resources