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.
Related
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?
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.
Using Google spreadsheet, I need a column to show relative row numbering, so that:
Spreadsheet rows can be moved around, and numbering stays relative (meaning that if I move row number 12 between rows 4 and 5, this row becomes number 5, previous 5 becomes 6, etc.)
Using a condition based upon a cell value in a given row, the row numbering cell may be empty (or not); if empty, that row number is being skipped, and numbering takes back up in the next row where the condition is unmatched.
Here is an example:
| Row nbr | B col. | [Explanation] |
|---------|:-------:|-------------------------------------|
| R01 | Value 1 | |
| R02 | Value 1 | |
| R03 | Value 2 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R04 | Value 2 | Numbering takes up |
| R05 | Value 1 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R06 | Value 2 | Numbering takes up |
| ETC. | | |
Here, the condition (to skip numbering) would be "IF corresponding B cell = Value 3" (then skip numbering)
Right now, I'm using a formula that matches requirement #1 above:
=ROW(INDIRECT("A"&ROW()&":A"))-9
(The trailing "-9" is just an offset so numbering can start at 01 from row 10).
So basically, I need to adapt (or change) this code so that besides relative numbering, for row N, if corresponding B column cell value = XYZ, then A column cell is empty (vs. numbered): that row is being skipped, and numbering takes back up from N on the next row where the B cell value ≠ XYZ.
Here's a Google spreadsheet example.
Many TIA's.
I strongly recommend not to use ROW() with explicitly specified offset in formula because should you delete/add rows above your table, your will have to adjust formulas in all cells. Here's my solution (column A:A is row numbers, B:B - values, start adding formula in cell A10):
=IF($B10="Value 3","",ROWS($B$10:$B10)-COUNTIF($B$10:$B10,"Value 3"))
Or if you insist on relative rows (change 10 to your offset from top):
=IF(INDIRECT("B"&ROW())="Value 3","",ROWS(INDIRECT("B"&10&":B"&ROW()))-COUNTIF(INDIRECT("B"&10&":B"&ROW()),"Value 3"))
I have two columns of data, one with dollar amounts and another with a text value. I'm trying to create a formula at the bottom that will add together only the values in A for which the corresponding row in column B equals "Yes". So in the example below my formula would return a sum of 1000:
| A | B |
|500 |Yes |
|150 |No |
|500 |Yes |
|533 |No |
|1000 |
My actual spreadsheet has many more rows, so I want a formula that can compare the entire range in column A against the entire range in column B, row by row. Is this possible to do without having to set up a macro?
Please try:
=SUMIF(B1:B4,"Yes",A1:A4)
Adjust the ranges to suit but ensure they are of equal size.
So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel