In excel, copy separated rows into sequential rows - excel

Challenge: In excel, on sheet 1, every 13th row contains results from the preceding 12 rows. I would like to dynamically copy the results from each 13th row of Sheet 1 to Sheet 2, Rows 1,2,3…, preferably without VBA. Any suggestions?

As long as your sheets are named Sheet1, Sheet2, etc, you could use something like this in Cell A1 of sheet2 and then copy and paste down:-
=INDIRECT("Sheet1!A"&ROW()*13)
This would give you the value of every 13th row of sheet 1.

Don't use INDIRECT. It is volatile and slow.
Don't use ROW. It is susceptible to errors from row deletions and other problems.
Instead use INDEX and ROWS:
=INDEX(Sheet1!A:A,ROWS($1:1)*13)

Related

Extract only rows that are not in both sheets into a third sheet

I have 2 excel sheets with similar column values (legal_id). Is there a way to extract only rows that are not in both sheets into a third sheet? For example if social security number 111111 isn't in both sheets, then that persons row would be placed in the third sheet..please see images below.
Sheet 1
Sheet 2
Sheet3_DesiredResults
Before I get backlash about not attempting code this is what I tried,
I thought this formula would highlight true or false to values that are not in the same sheet, then I could just delete every field that returned true to be in both sheets , but it doesn't work. I'm not a programmer, I need help. Please don't tell me to take a VBA tutorial.Instead of making a third sheet , I made a helper column on the first sheet and used the formula:
=(ISNA(MATCH(A2,Sheet1!A:A,0)))=FALSE
Like anticipated in my comment, you might use 2 ranges in the third sheet and the COUNT.IF function. The formulas you need are these:
=IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0)
.
=IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0)
Place them in 2 proper cell in the third sheet (let's say A2 and E2), drag them to cover the two lists. Empty cells or cells with IDs in both Sheet1 and Sheet2 will return 0. If you don't like 0 and you prefear "", you might use these:
=IF(IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0)=0,"",IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0))
.
=IF(IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0)=0,"",IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0))
I have solved your query. Please have a look below.
First as expected, i created 2 sheets with same data as mentioned in image for simplicity.
Sheet 1 with Helper column
Sheet 2 with Helper column
Step 2 : I converted the sheet data into table for efficiency.
Step 3 : I used the COUNTIF function and IF function in Sheet 1 Helper column throughout.
=IF( COUNTIFS(Sheet2!Legal_id, [#[Legal_id]]) = 0, "N/A","" )
Similiarly we have to implement this formula in Sheet 2 Helper column.
=IF( COUNTIFS( Book1!Legal_id, [#[Legal_id]]) = 0, "N/A", "")
Explanation of above formula: The COUNTIF Function counts number of corresponding occurrences of Legal_id, in Sheet 2 Legal_id column. If count = 0 i.e means legal_id is not present in Sheet 2, so we use IF statement to assign 'N/A' value in Helper column else nothing ''.
Same explanation follows for sheet 2.
Now We Filter the Rows with N/A values to delete as mentioned by you in comments. or Insert it in third Sheet by copy paste.
The best way to accomplish your task is to use vba. But, if you want to use the ISNA(MATCH formula, you will need to wrap your formula in an IF statement and place the formula in each cell in Sheet3.
STEP 1: Paste the below formula in Cell A2
=IF(ISNA(MATCH(Sheet1!A2,Sheet2!A:A,0)),Sheet1!A2,"")
STEP 2: hold down CTRL+SHIFT+ENTER to enter it as an array formula
STEP 3: Hover over the dot in the right-bottom corner of the cell and drag down to the number of used rows you have in Sheet1 Note: the formula will change for each row
STEP 4: Then drag across to Column C Note: the formula will change for each column
The data from Sheet1 that is not in Sheet2 will now be in Sheet3, separated by blank rows, you can select the blank rows and delete them.

How to stop Excel from changing referenced cell range

My formula in Sheet 1, A3 is
=SUMPRODUCT(('count May'!$D$2:$D$2000=Categories!$A$5)*('count May'!$E$2:$E$2000=Categories!$B$3)*(ISNUMBER(SEARCH('count May'!$F$2:$F$2000,Categories!$C$4))))
Count may is the sheet for the month of may(I'm doing this for a full year), categories is the sheet that has my helper table. When I paste the data from the export with about 1600 rows one column with different companies, another column with different employment status,another column with various locations i.e company $A$5, fulltime $B$3, Location $C$4 into any month sheet the cell that has the above formula changes all the cell ranges from $2:$2000 to $1609:$2000.
=SUMPRODUCT(('count May'!$D$1609:$D$2000=Categories!$A$5)*('count May'!$E$1609:$E$2000=Categories!$B$3)*(ISNUMBER(SEARCH('count May'!$F$1609:$F$2000,Categories!$C$4))))
I then get #Value! or #N/A in A3. Essentially the pasted data makes the formula range in A3 start from a few rows after the last pasted data cell. I have tried to change $D$1609:$D$2000 to $D:$D, $E:$E, $F:$F, but I get a excel cannot complete this task error, I tried changing $D$2000 to $D$1600 but that didn't work and is not feasible because every month will have a different number of rows. I tried cut instead of copy but still happens.
If it is any help the data is put together in one sheet, column D,E,F and then I copy or cut and paste in the month sheet and then the formulas are in a different sheet but reference each month.
Any help is much appreciated.
I'm joining in late here so may be you may have already fixed your bug (if it's the case lets know how!).
If I understand correctly, you have sheet 'Count May' with a formula in A3 and you're a copying data (range A1:F1600) into 'Count May' (presumably in A2) in order to use your formula. Doing so messes up the reference in the formula in A3.
The only way I was able to recreate this was by copying/pasting entire rows, (i.e. rows 1:1600), instead of the range of cells needed, (i.e. A1:F1600). That would insert 1600 rows in 'Count May' and effectively push your reference down. Your second reference wouldn't get moved because it references to another sheet, 'Categories' untouched by the copy/paste. Your problem should be fixed by copying the range of cell needed (instead of entire rows) and selecting A2 (not row 2) to paste.

Excel formula to pull data from last 5 rows of a cell range that has new rows added daily

As the title suggests, I have a worksheet (sheet1) that has lots of data that spans columns A-E and with rows that are added daily, What I want to do is on a separate worksheet (sheet2) show the data from the last 5 rows of sheet1.
Providing there is continuous data within column A on Sheet1, you could also use the INDIRECT() and COUNTA() functions.
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-4)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-3)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-2)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A)-1)
=INDIRECT("Sheet1!$A$"&COUNTA(Sheet1!$A:$A))
You would need to amend the column letter within the INDIRECT function for each column of data which you wish to view on Sheet2.
In an appropriate cell on Sheet2, use this formula,
=INDEX(Sheet1!A:A, MATCH(1E+99, Sheet1!$A:$A)-(ROW(1:1)-1))
Fill right for a total of 5 columns then fill those 5 cells down 5 rows.
That formula will find the last number in a column. This is often the case as the left-most column mat hold an ID number. The same reference point should be used to collect cell values from other columns to avoid the confusion that a rogue blank cell would create.
If all you have are text values then the formula in the first cell would be,
=INDEX(Sheet1!A:A, MATCH("žžž", Sheet1!$A:$A)-(ROW(1:1)-1))
Fill right and down as described above.

Continuous numbering with blanks - multiple worksheets

In Sheet1 I have 50 cells for numbering (column B) and my formula is
=IF(ISTEXT(C9),B8+1,"").
There will always be 50 rows and some could remain blank if there is no text in column C.
I would like to continue numbering on Sheet3, all the way through sheet20. So, if Sheet1 actually ends on number 10, I would like sheet3 to continue to number at 11, and if sheet 3 ends on number 20, I would like sheet4 to continue to number at 21, etc.
I have tried multiple formulas, but am having difficulty because there are blanks. Your help is much appreciated!
Use "MAX" to get the higher number, and use "INDIRECT" to look at the last sheet. So assuming you're using default names on the sheets, start by getting the current sheet name:
A1=REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")
Then get the sheet #.
A2=RIGHT(A1,LEN(A1)-5)*1
Multiplying by 1 gives you the number instead of the text. Now we can get the previous sheet name:
A3="Sheet"&A2-1
Now use Indirect to get the highest value in column C on the previous sheet:
A4=MAX(INDIRECT(A3&"!C:C"))
If we combine it, we get:
=MAX(INDIRECT("Sheet"&RIGHT(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""),LEN(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""))-5)*1-1&"!C:C"))
As long as your data starts in Row 2 (i.e. you have headers), here is the full formula as well:
=IF(ISTEXT(C2),IF(OR(ROW()=2,IF(ROW()=2,TRUE,MAX(INDIRECT("B2:B"&ROW()-1))=0)),MAX(INDIRECT("Sheet"&RIGHT(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""),LEN(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""))-5)*1-1&"!C:C"))+1,MAX(INDIRECT("B2:B"&ROW()-1))+1),"")
One way would be to put: =IF(ISTEXT(C4),COUNT(Sheet1!B4:B13)+1,"") in first cell of Sheet2, and then reuse =IF(ISTEXT(C5),B4+1,"") in all cells below.
If you would like to have all the cells with the same formula, you could move that COUNT to a hidden row just above the first one of your data.
Then you do the same thing with next sheet, just changing the naming.

Link two cells of a column in different sheets if a value in a cell of other column matches in other sheet

I have a workbook with 7 sheets containing part number of a product in column and its cost in adjacent column. And the 7th sheet contains total number of parts in all the sheets. I want to change cost of some products but then I have to do the same in all sheets. Is there a way by which it automatically finds and changes cost in individual sheets when i change it in the sheet containing total?
Use VLOOKUP on the first 6 sheets to match the price to each part number.
So, in each "cost" column on the first 6 sheets, enter this formula (assuming Cost on Sheet7 is still in column C):
=IFERROR(IF($A1="","",VLOOKUP($A1,Sheet7!$A:$C,3,FALSE)),"")
If you have header row(s) then just replace the two instances of $A1 in the formula with whatever the first row of data is (e.g. $A2), paste the formula into that row in column C on Sheet1, then drag-copy the formula down as far as you want. Repeat for sheets 2-6.

Resources