How to change this Excel formula - excel

i have this formula to get data to one sheet from another sheet.
But i need to have a formula that will get data from all the sheets between sheet "start" and sheet "end" i have about 80 sheets.
Thank you.
= COUNTIF(Huvudlager!$B:$B;"Skruvdragare")

There is not a clean and easy way to do this all in one cell.
You can however, take advantage of some nifty excel functions to help you with this, namely GET.WORKBOOK and INDIRECT.
Step 1
Define a Named Range called SheetList (or whatever you want) with the following formula:
=SUBSTITUTE(GET.WORKBOOK(1),"["&GET.WORKBOOK(16)&"]","") creates an array of worksheet names within the workbook. The substitute function gets rid of the workbook name in the array.
Step 2
Highlight 80 rows (since you said you have 80 sheets) of data on the sheet where you wish to count your data. Then type =TRANSPOSE(SheetsList) into the first cell and Ctrl+Shift+Enter. Your sheet list will appear in the 80 rows. Transpose is needed so the list goes down the rows instead of across columns.
Step 3
Write the following formula next to each sheet =COUNTIF(INDIRECT(A1&"!$B:$B"),"Skruvdragare") assumes first sheet name is A1.
Edit: You'd be better served to define the row ranges in the COUNTIF formula, since counting every row in a column is very efficient, especially if not all the rows have data. So, use the max number of rows you know will have data across all the sheets, for example: INDIRECT(A1&"!$B$1:$B$1000")
Step 4
Write a formula to sum the counts of each sheet.

Related

Filter rows from multiple sheets in Excel without VBA

I have an Excel file with three sheets, with data in each sheet organised in the same manner - headers are the same.
Without using VBA (as macros are not allowed by my organisation's security policy), I would like to find all rows from all sheets that meet a simple column value check and show those rows in a separate sheet.
For example:
Sheet2 has,
Sheet3 has,
Sheet4 has,
I want sheet1 to have all rows from sheets 2-4 with Header7 column value = "Hit",
What I have achieved so far is, using an array formula I could get all the "hits" from one sheet in sheet1.
The formula for A2 to A6 in sheet1 is as below, with the ROW(1:1) changing to ROW(2,2) and so on from A3 onwards. Columns B to G use the same formula with range adjusted accordingly.
{=IFERROR(INDEX(Sheet4!$A$2:$A$6,SMALL(IF(Sheet4!$G$2:$G$6="Hit",ROW(Sheet4!$A$2:$A$6)),ROW(1:1))-1,1),"")}
What this does is a bit complicated. In short, it creates an array of either FALSE or row numbers based on Hit and then finds the index of the non-false values.
Now, I can solve the last part of combining the idea to include all sheets in two ways (I think).
Have another temporary sheet (sheet5) with all rows from sheets 2 to 4. Update my formula in sheet1 to use sheet5 instead of 4.
Have the range Sheet4!A2:A6 etc changed to include a 3D reference like Sheet2:Sheet4!A2:A6. But this doesn't work, and the documentation for 3D reference doesn't mention that it works with array functions.
PS: I don't have Power Query, which seemed to have an easy way to create a new sheet with all rows from multiple sheets, because I work on a Mac (MS Excel for Mac).

Using internal excel sheet name (i.e. sheet1, sheet2, sheet3) to sum a cell across multiple sheets

I'm trying to sum the same cell across multiple sheets. The number of sheets increases by one each week and will be a new Sheet1. Each sheet will get a date for it's name. The last sheet will have the sum totals. The three sheets prior to that will contain instructions. i.e. 20 sheets, data on sheets 1-16, instructions on sheets 17-19 and totals on sheet 20.
This Sum across dynamic number of sheets question uses a User-defined Function, =autosum, in each cell and could work. I would rather use VBA to create a macro. I know how to get total sheets and sum across all the sheets, where I'm lost is how to sum across (total sheets -4), i.e. sheets 1-16.
code I'm already using is
Dim sheets as Integer
sheets = Application.sheets.Count
=SUM('FirstSheet:LastSheet'!D6)
How do I get
=SUM('FirstSheet:(LastSheet-4)'!D6?
I want to use the internal excel sheet1, sheet2, etc. vs the date name on each sheet, at least for FirstSheet. I can hardcode LastSheet since it won't change.
You shouldn't need to use VBA, you can use the default sum formula. I recommend creating two blank sheets (e.g. "Start" and "End"), ensure that "Start" is always before the first sheet you want to some and "End" is always immediately after the last sheet you want to sum. Then, a formula like this would do what you're asking:
=SUM(Start:End!A1)
Edit: If the name of the first and/or last sheet that should be summed is static, you could avoid using the "start" or "end" placeholders and replace them with the names of the first/last sheets that should be summed.

Fill data in excel sheet from master list from another sheet

I have data in two separate excel sheet in single file.
In the first sheet, I have two columns...like this
Sheet1
In the second sheet, I have one of the column which is same as Name in Sheet1. However, it does not have second column where I want to bring the value referring to the sheet 1.
Here is the second sheet.
Here in second column, i.e. Color I want to bring the value from first sheet.
I am using Libreoffice but can use excel as well. Pls suggest how I would do this in excel / libreoffice.
Solution for Excel...
So use sheet one as the reference sheet. Sheet two as the one you want to fill.
In B2 on Sheet 2 enter this formula:
=vlookup(A2,Sheet1!$A$1:B$6$,2,FAlSE)
Then drag down.
This is assuming that your reference in sheet one is in columns A and B and goes from rows 1 to 6.
Hope this helps.
One of the easier ways to do this would be to use VLOOKUP. So this requires 4 inputs:
The value you are searching for
The array you are searching in
The column where the value you want to return is in
"FALSE" to list if you want an exact match between the value you are searching for and the array you are searching in.
So in your example, we will use the worksheet where you only have the Names listed as the worksheet you are putting the formula, so something like this in B2:
=VLOOKUP(A2,sheet2!$A$2:$B$6,2,FALSE)
So this would lookup the value you show in worksheet 1 cell A2.
Then go to workbook 2 and match that value with what is in A2:A6.
Then lookup what is in column 2 for your answer.
And return what is in column 2 only if worksheet 1 cell A2 and something in worksheet 2 range A2:A6 is an exact match.
There are other ways, but for your example, this should be easiest in EXCEL. This only works if the value you are searching for is to the right of the value you are looking up. If you need to go to the left, INDEX/MATCH would be better (but not required here).
Hope this helps!
JW

Prevent #ref when cell deleted

I'm importing a text file into one sheet, eliminating un-needed lines, while formatting the data on the second sheet.
I have all the formulas on the second sheet set up, referencing cells on the first sheet.
The problem is that after deleting the un-needed lines and the data moves up, the formulas for the deleted lines say #ref. I want the formulas to use, say Sheet1!B2 no matter what data is there.
I see that Indirect works, so the next question is, how can I copy the Indirect function down a colum of 500 rows with each one having the right reference?
Thanks
I had this same problem recently so just passing along the answer I got. Index functions will help. Below you can see one where the sheet name is reference in cell a1 and it will return the value in cell a2 of the corresponding sheet.
=INDEX(INDIRECT($A1&"!2:2"),COLUMN(A:A))
If you only need to reference cells on the same row, including cells on different sheets on the same row, there's an easier way than Indirect.
If you write in A42:
=#B:B
it will look up B42.
If you write in A42:
='Sheet 2'!#X:X
It will look up X42 on Sheet 2.
If you delete the top rows on Sheet 2, the formula on Sheet 1 will point to the new X42 - no #REF! errors.
As long as your formulas in Sheet 1 just need to reference cells on the same row in Sheet 2 - so the formula in 'Sheet 1'!A42 might want 'Sheet 2'!X42 but not 'Sheet 2'!X43 - you can just put the column names as inputs into the formula. Otherwise you'll need Indirect.
For bonus points, name the columns in Sheet 2, so instead of ='Sheet 2'!#X:X you could write =cust_DateOfBirth for example.

How to input two arrays in VLOOKUP?

I have a worksheet in Excel 2013 with two sheets: Sheet 1 and Sheet 2. I am applying a formula in both the sheets in the same column (G). The data is in more than 100,000 rows that's why I can't put it in one sheet only.
The problem is that I want to use VLOOKUP in both sheets in a way that the function looks up in both sheets in the same columns (arrays) i.e. A and B columns in sheet 1 and sheet 2 and get the value from column B i.e. column 2 within VLOOKUP function.
How can I add reference to the other sheet?
I doubt a complete solution is possible with VLOOKUP because, for instance, the corresponding ColumnB values may differ even where a ColumnA value is the same on both sheets. So without VBA (or possibly merging your sheets) you may have to compromise, so I offer only a partial solution, based on Excel 2007.
This 'looks up' in the 'other' sheet and only defaults to the 'same' sheet where the first attempt is unsuccessful. It uses INDEX and MATCH because likely quicker than VLOOKUP for high volumes. The formula I have applied for Sheet1 (in G1 and to be copied down) is:
=IFERROR(INDEX(Sheet2!B$1:B$6,MATCH(E1,TwoArray,0)),INDEX(B$1:B$7,MATCH(E1,OneArray,0)))
where the OneArray and TwoArray are named ranges for parts of ColumnA for the two sheets and the link values are expected in ColumnE (the formula in Sheet2 is similar):

Resources