Prevent #ref when cell deleted - excel

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.

Related

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

reference same cell from multiple sheets

I am trying desperately to use the INDIRECT function to pull the values from the same cell on multiple worksheets but all I keep getting is #REF. I have all the sheet names in column I. I tried =INDIRECT(I2&"A1") with I2 being the cell with the sheet name and A1 being the cell on that sheet I want to pull the data for. I'm not sure what's going wrong....
You need an exlamation mark.
Try =INDIRECT(I2&"!"&"A1")
It works for me.

Excel offset where reference is to another worksheet

I am trying to create a series of formulas in Excel that use a reference on sheet 2, via a dependent cell on sheet 1 to display data from different rows on the sheet 2. I have searched here for some tips on this problem and discovered that using Offset is probably the solution, but I need some help on the last piece of the puzzle.
Basically, I need to be able to enter into A1 on Sheet1 the formula "=Sheet2!A1" and then, via an =offset formula have cell A2, A3, A4 etc on sheet 1 automatically display the contents of specified cells elsewhere on row 1 in Sheet2.
The reason for this is because sheet 2 is a large database and i'm trying to set-up sheet 1 as a summary sheet where users can display select information.
I can see how I could use the =Offset function in cell A2 on Sheet 1 to make this work if all the data was on one sheet, and how I could set the reference within the Offset formulas to =sheet2!A1, but what I want is for the reference to be A1 and for the offset to follow the target of A1 into sheet 2 and then locate the data there.
Can anyone help? Is this even possible? Am I going about this the right way? I can't use macros because the spreadsheet will be used by people who cannot have macros on their PCs
Thanks
I had this same question I'll share my solution.
Solution:
=OFFSET((INDIRECT(ADDRESS(1,1,,,"Sheet2")),ROW(),0,,)
References:
OFFSET(starting point, num of rows, num of col, [height], [width])
ADDRESS(row_num, col_num, [abs num],[a1],[sheet])
OFFSET can't take a reference from another sheet by itself. Neither will ADDRESS for some reason. In order to reference another sheet within a formula, you need to nest ADDRESS within INDIRECT like so:
INDIRECT(ADDRESS(1,1,,,"Sheet2"))
These two nested functions point to your Sheet1 cell A1. The first argument in OFFSET is your starting point, so you need to take the two nested functions and insert as the first argument to OFFSET like so:
=OFFSET((INDIRECT(ADDRESS(1,1,,,"Sheet2")),1,0,,)
Now you need to get that "1" to increment. The best way to do this is the ROW() function, which can return the row number of the current cell (for you, this is Sheet1 A1, returning a 1). Now we have:
=OFFSET((INDIRECT(ADDRESS(1,1,,,"Sheet2")),ROW(),0,,)
If you had started your formula in Sheet1 A5, instead of ROW(), you would need to insert (ROW()-4). Row 5 minus 4 equals 1. That's the part that I needed.
Hopefully this helps someone.

How to change this Excel formula

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.

VLOOKUP & Inserting Text That Corresponds To The Cell

I'm having difficulty getting my vlookup formula to pull url data from another sheet (Sheet 2) and insert added information to the url based on what is in its A cell on Sheet 1.
For example,
The vlookup formula =VLOOKUP(B2,Sheet2!A:B,2,FALSE) will check to see if B2 (Sheet 1) matches with Data on Sheet 2. It will then return the data it has matched:
=HYPERLINK("http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber="&Sheet1!A2&"&search.searchType=16&search.javascriptValidated=0&appmode=guest")
I then want the url link to insert whatever text is in the Sheet 1 A cell.
The formula I have used does this nicely, but I want the formula to correspond down the workbook for whatever is in cell A, not just A1 i.e. Sheet 1 A3,Sheet 1 A4....
How can I do this?
Thanks
I'm not sure if I completely understand what you are asking but allow me to share my experience with what I believe was a similar problem.
My solution was an offset/match formula. I used a formula similar to:
=OFFSET($A$1,(MATCH(B$2,'Sheet2'!$A:$B,0)+$A1),0)
And had a list of values in column A that corresponded to the distance that row was to the object cell I wanted to keep constant. Then I used autofill to fill column a down the sheet as far as I filled the formula. This way offset refrence changed on each row and I was still able to auto fill.
I hope that helps

Resources