Increment row reference based on index in selection, and not same row number between sheets - excel

I have a workbook containing two sheets. Sheet 1 has values in column A for every row up to row number 2000. Sheet 2 should duplicate the values over multiple rows for each row in Sheet 1. Like this:
Sheet1:
a1 | 123
a2 | 456
a3 | 789
and for Sheet2:
Sheet2:
a1 | 123
a2 | 123
a3 | 456
a4 | 456
a5 | 789
a6 | 789
The duplication is fairly simple, where I just put a reference of the next rows to the row collecting the row value from Sheet1:
a2: =a1
However, selecting and dragging rows a1 and a2 in Sheet2 to get the corresponding formulas copied over to the next rows, the formula does not reference the correct rows in Sheet1. Something like this occurs:
Sheet2:
a1 | 123
a2 | 123
a3 | 789
a4 | 789
Where cell a3 in Sheet2 references cell a3 in Sheet1, instead of cell a2 which is the next row. I have tried several functions with index, offset etc. but none of them seem to circumvent the automatic same-row-reference between the worksheets. Any quick ideas?

"generic approach" imho is either one of these.. :
Just edit the "2" in the 1st comment ans.
use ROW() and argument for OFFSET()
'Manually' build the reference using INDIRECT
set the 1st 2 row manually, 3rd row onward use =IF(A2=A1,INDIRECT("Sheet1!A"&(row()+1)/2,TRUE),A2) and drag downwards.
Is this what you are looking for?

Related

How to change column to header in excel?

a1 | b1 | 0.1
a1 | b2 | 0.2
a2 | b1 | 0.3
a2 | b2 | 0.4
how to transform this table to
xx | a1 | a2
b1 | 0.1 | 0.3
b2 | 0.2 | 0.4
Make use of Pivot tables. Enter Column A as Column labels, Column B as Row Labels and Column C as Values. If values are not sum by default, change it to Sum.
Output:
You can remove the headers deselecting the Field Headers in Options tab.
You can also hide the grand totals by clicking on Options under the same tab. (Located at the left corner of the screen).
If you don't want Grand Total and other..., you can use Index:
Create a New Sheet with your Header xx, a1, a2
Copy column B b1, b2,...to the new sheet under xx
select the Data b1, b2,... in the new sheet
Remove Duplicates
Distinct and unique values will remain
Under a1 write the following formula:
=IFERROR(INDEX(Sheet1!$C$1:$C$4,MATCH(B$1&$A2,Sheet1!$A$1:$A$4&Sheet1!$B$1:$B$4,0)),"")
Array Formula press Ctrl+Shift+Enter at the same time instead of Enter
and drag it in the same row and down in columns
Change A1:A4, B1:B4 and C1:C4 to correspond your last row of Data but keep $ for fixed references

Fill blank cell in Excel with value with same ID

I'm not so advanced in excel I need help if is it possible to do.
I have an excel with this column:
ID - Value1 - Value2
I need to update the value1 (or value2):
- only if are blank AND only if the row has the same ID
I make an example, I have this table:
ID Value1 Value2
A1 1 100
A2 2
A3 3
A4 1 200
A5 2 250
Iwould like to fill all the empty cell in this way
ID Value1 Value2
A1 1 100 200
A2 2 250
A3 3
A4 1 100 200
A5 2 250
Thank you for any help.
Ok, so your data is a mixture of numbers and texts. You can generate two new columns with the desired values using formulas. Choose two new, adjacent columns, say D and E, and enter this CSE formula in row say in cell D2:
D2:
=IFERROR(IF(ISBLANK(B2),INDEX(B$2:B$99,
MATCH(1,($A$2:$A$99=$A2)*(1-ISBLANK(B$2:B$99)),0)),B2), "")
CtrlShiftEnter
Enter the formula in D2 with CtrlShiftEnter and then copy/paste in the cells of columns D and E (or as I said any two adjacent columns).

Sum fields in a column if there is an entry in a corresponding row in another column

Assume the following data:
| A B C
--+------------------------
1 | 2 3 5
2 | 2 3
3 | 4 4
4 | 2 3
5 | 5 6
In cell A6, I want Excel to add cells C1, C2, C3 on the basis that A1, A2 and A3 have data in. Similarly, I want B6 to add together C1, C4 and C5 because B1, B4 and B5 have data.
Can someone help?
In A6 enter:
=SUMPRODUCT(($C1:$C5)*(A1:A5<>""))
and then copy to B6:
A simple SUMIF formula will work
=SUMIF(A$1:A$5,"<>",$C$1:$C$5)
Place that formula is cell A6 and then copy it to B6.
You can create another column, e.g. AValue, with the formula =IF(ISBLANK(A1),0,A1) in it. This will return 0 if the cell in A in the corresponding line is empty, or the value from the cell in A otherwise.
Then you can just sum up the values of the new column.

copy cell to selected date range

I have a list of dates in B2:GF2. I enter 2 dates - "A1 start date and B1 End date". I also enter a value (number) in cell C1. The value in C1 should be copied to all the cells under the list of dates from A2:GF2 between the dates choosed in A1 and B1. Let the copied value between the row A3:GF3.
E.g.:
A | B | C
Row1 3/3/2015| 5/5/2015 | ABC
Row2 2/2/2015 | 3/3/2015 | 4/4/2015 | 4/23/2015 | 5/5/2015....
ABC ABC ABC ABC
In cell C4, type =IF(AND(C3>=$A$2,C3<$B$2),$C$2,""), then just copy cell C4 across.

Need to match data in different sheets and replace data in another cell if it's a match

I need to match data in column A2 and so on in sheet 1 to data in column A2 and so on in sheet 2. If the data in column A of sheet 1 and sheet 2 match I need the data in column B & C of sheet 2 to replace data in column B & C of sheet 1. I know VERY little about doing this kind of stuff so any help would be GREATLY appreciated!
SHEET 1
A B C
2 12345 5.35 9.95
3 15874 4.22 10.99
4 11111 2.24 5.99
5 98745 5.33 9.95
6 88552 4.24 8.95
SHEET 2
A B C
2 11111 2.09 5.79
3 12345 5.11 9.89
4 88552 4.01 8.79
NEED SHEET 1 to change to
A B C
2 12345 5.11 9.89
3 15874 4.22 10.99
4 11111 2.09 5.79
5 98745 5.33 9.95
6 88552 4.01 8.79
On a third sheet use these functions
column a ='sheet1'!a2
column b =if('sheet1'!b2='sheet2'!b2,'sheet2'!b2,'sheet1'!b2)
column c =if('sheet1'!c2='sheet2'!c2,'sheet2'!c2,'sheet1'!c2)
Copy sheet3 and paste the values into sheet1.
This should work unless column a does match. or if you need to do this dynamically. If column a doesn't match some vlookups can be thrown in.
I your data does match in column a your formulas could look something like this.
column a ='sheet1'!a2
column b =if(not(iserror(vlookup(a2,'sheet2'!a:c,2,false))),vlookup(a2,'sheet2'!a:c,2,false),vlookup(a2,'sheet1'!a:c,2,false))
column c =if(not(iserror(vlookup(a2,'sheet2'!a:c,3,false))),vlookup(a2,'sheet2'!a:c,3,false),vlookup(a2,'sheet1'!a:c,3,false))
this is too much to put in a comment so I'm putting it in answer.
The way I under stand is, since sheet1 has more data, you only want to be doing this comparison when sheet1 and 2 both have data on the row. so If sheet1 has data in rows 1 - 100, and sheet2 has data in rows 1 to 50, you only want to be doing this comparison for the first 50 rows in sheet1 right?
So, rather than copying and pasting formulas, what you can do is, in sheet1, find an unused column. go to the first row. in the formula box, type: "=if(" without the quotes. now, select the first cell to compare, according to your example you'd select sheet1, A2. then type "=" without quotes. then select the second cell you want to compare - in your example, sheet2, A2. then type "," without quotes. then select the cell from which you want the data if the first 2 cells are equal. in your example, sheet2 B2. then type "," without quotes, then select the cell with the data to use if the first 2 cells are not equal. in your example, sheet1 b2. then type ")" without the quotes.
so using your example, the function would look similar to how bigtree had it: =if('sheet1'!A2='sheet2'!A2,'sheet2'!b2,'sheet1'!b2)
so, this will compare sheet1 cell A2 with sheet2 A2 and if they are equal, the cell you put the formula in will the have the value of sheet2 b2, and if they are not equal, the cell with this formula will have the value of sheet1 B2. then, drag this formula down for however many rows you want, and the formula will adjust automatically for each row. you'll see the numbers increase. then, select the column with the formulas, right click and select copy, then right click and go to paste special, and click values. this will make it so the column contains only the values, not the formulas, now you can paste this data in column B sheet 1.
you can reuse this formula for whatever columns, just follow the steps.
HTH, good luck!

Resources