How to duplicate a block of cells that contain formulas without losing reference? - reference

I think the solution listed here might be one that I can use but I can't seem to get it to work.
The formula listed in that post is:
=INDIRECT("sheet1!B"& ROW(A5)/5)
I want to duplicate a timesheet I am creating, and in it, there are formulas that reference another sheet within the same workbook. I have taken a screen print for illustration, and highlighted the yellow boxes that contain formulas that I need copied down but without loosing reference.
As it stands now, when I try to paste formula, it calculates all the lines in between the yellow boxes so numerically, it's not referencing the correct cell in the different sheet.
I am using VLOOKUP and here is the code I have used:
=IFERROR(VLOOKUP(B6,Sunday!$A6:$K6,6,FALSE),"")
However I can't figure out how to combine INDIRECT with the VLOOKUP. There are 29 rows between B6 and B35. Same between G5 and G34, and also between D12 and D41.
Can someone help me figure out a way to be able to copy the whole timesheet and duplicate it again and again? I need 260 of them. :(

Related

Excel problem for beginners: #REF! Error When referenced Row is deleted or Added

I have data in column A which is copied in another random location. The copied data could also be in column B-Z, AA... Etc, Or alternatively could be on a new sheet by setting the column =Sheet1!A1 for example.
In the attached image I initially had a,b,c...through to f.
In this example,data is copied in the same column just further down by entering at A10 =A1 and copying down as required.
When what was A5 is deleted as a row to remove 'e' you can see that A14 now has the #REF! Error. This is strange to me because although the row is deleted the data has shifted up one. so A14=A5 which previously returned 'e' should now return 'f' but instead returns the error. Initially I thought that this is because the data is in the same column but the same error is returned if on another sheet for example If I set A1=Sheet1!A1 and then delete a row on sheet1.
If you drag down the copying formula again the error is corrected But surely this can be made to happen automatically? Especially if dealing with large amounts of data.
Surprisingly this error doesn't seem to have an obvious solution posted online. I wanted to create this post for anyone to suggest feasible solutions for those starting out with excel (including myself).
If you use a general formula like =A5 then you will face this issue. Excel is not built to handle this internally.
The best way to avoid this error is to use the OFFSET function. This function is dynamic so it will update when cells are added or deleted.
Hope this fixes your problem.
Setting the column to a range instead of =A1 and drag down, this seems to solve all problems.
e.g. =A1:A7 will return a-h but also if a row is then deleted/inserted the formula adapts accordingly.
Avoid #REF
The best way I found (so far) is the following formula in cell A10:
=IFERROR(INDEX(A$1:A$9,ROW(A10)-ROW(A$10)+1),"")
You can delete any or all except two rows. Two rows are necessary for the range A$1:A$9 to work. If you would leave only one row, the range would be A$1:A$1 and could not be increased anymore.
You can insert new rows before the last row (9). If you insert a row after the last row (9), it will not be affected by the formula.

Increment numbers starting from Zero in any cell without specific reference in Excel

I want to increment numbers starting from Zero in any cell without specific reference in Excel without VBA. I know to use col()-col($A$1), or a helper column, a1+1, auto-fill options. They all require a reference cell which much be changed if the starting cell is changed. but I have many offset formulae which reference the same ranges but from different cells.
Essentially what I've been unsuccessfully trying to do is have the one formula to paste into any cell, named range or other formula to increment by 1 starting from zero in any cell.
I don't think it should be hard to to, but so far my search has not yielded desired results as per my requirements.(As a last resort - after looking through all the aisles 4 times in every supermarket, twice) I'm asking the question.
What I want is:
0
1
2
3
4...etc. with rows or columns. in any cell without having to reference a absolute cell because I'll have to keep changing that reference with every formula in a different cell.
OFFSET(payments!$E$14,,GCD((COLUMN()-COLUMN('error test'!$B$1))*5),COUNTA(OFFSET(payments!$E$14:$E$522,,GCD((COLUMN()-COLUMN('error test'!$B$1))*5))),1)
(COLUMN()-COLUMN('error test'!$B$1) - this part is just to start at 0 but I have to keep changing the reference $B$1 whenever i put the formula into a different cell or table or pull data from another range. I have many like this, each one has to be carefully examine and changed accordingly to make sure the reference is correct.
Once I added an extra column to my data table, I had to go through every cell and every formula, name ranges, conditional formatting, and change the reference.
Surely there must be a way without using VBA to start counting from zero without needing to manually change a reference every time it moves.
I've tried variations of sum(row()-1+row()), mod, gcd. could there be a way to have an absolute reference move with a cell?
I've just figured it out! i can't believe the answer eluded me for so long!
columns($A$1:a1)-1
This will give me a result of zero, and increments when filled across.
0 1 2 3 ...
rows($A$1:a1)-1 will do the same for rows.
I know it references a cell, but this way it doesn't matter which cell this formula is placed into, the result will always be the same. However if you insert of delete cells, just refill the formula through the desired cells.
I think this will be much easier than column()-column($A$1).
Thanks guys for your help.

Pull data using VBA, Vlookup or Index Matching

Here is my question. I have tried to use Vlookup and receive an #NA and then I have tried to use Index Matching and the formula breaks and the returns are not all present. I receive some 0's and some #REF!'s in the column of my formula.
This is what I am trying to do. I have workbook with 2 work sheets. The first worksheet called 'brazil' is where I have written my formula in the column D.
Now, what I am trying to do is match up the email address from worksheet 'brazil email' and the worksheet from the 'brazil' and then pull the information from the cell in the 'brazil' worksheet a column that matches with the email from the formula.
The snippet shows the formula works in row 3 column D and returns the information from column A(employee), but breaks after a few rows and works intermittently.
Current my formula looks like this: =INDEX(A2:A34, MATCH(C2, 'Brazil email'!$A$2:$A48, 0))
Here is the snippet of the other worksheet: enter image description here
If you have any ideas on what could be causing the breakdown of my formula, that would be great.
I am willing to share a sample of the spreadsheet with you if needed. Thanks for any help. :)
Any other methods, like an alternate vlookup or vba would be great. :)
UPDATE 3/15:
I was able to update my formula and locked it down as per the great advice given on the below comment. :)
This is the latest update. I am still receiving #REF! on some of my cells. I copied and pasted in case there was a space and verified that the column is set to general and not text.
What could possibly be giving me the #REF! when it should be the data from the matched and index cell. I see the other rows worked but for some reason some of the cells on column D didn't update with the data from column A.
Please assist since I have 25,000 lines of this I have to sort through and trying to work smarter not harder. :)
I have removed the original snippet since the update given has corrected some of the errors. Here is the latest image with the current #REF!, Please assist: enter image description here
Looking at your formula, it seems that the first parameter should be locked:
=INDEX($A$2:$A$34, MATCH(C2, 'Brazil email'!$A$2:$A$48, 0))
When you copy your formula down, Excel will shift that first bit out of bounds.
UPDATE:
The #REF! usually comes from copying/pasting formulas or deleting/moving referenced data.
What I can think here is to make sure to put the working formula in the top cell and paste all the way down.
Also important: Added another lock to the formula (didn't see it before), on the referenced range inside the MATCH section.

Copying cells from one worksheet to another if a column matches a value

I'm trying to use formula to copy data from one worksheet to another where a column matches a certain value.
To be more specific, I want Working!A2:E100 to contain Data!A2:E100 but only for those rows where Data!C2:100 contains the value "Fixed".
Doing this with leaving blank rows is simple, I just create the formula:
=IF(Data!$C2="Fixed", Data!A2, "")
And copy that formula across all the cells.
But then I thought I'd get clever and have it not copy across blank lines, and entered a maze of unclear excel tutorials and vague error messages.
I've created this formula:
=INDEX(Data!A2:Data!A200, MATCH("Fixed", Data!$C$1:Data!$C$200, 0))
And entered it as an array formula using ctrl shift enter.
However all I get is the contents of Data!A2 repeated over and over in every cell of my spreadsheet.
Does anyone need to know what I need to do to make this work?
This is my attempt at a local prototype following the example in BruceWayne's answer, the results are visible:
As you can see "Row 2" just appears repeatedly in the result column. Excel doesn't seem to have an easy way to see what version it is any more but this seems to be a pretty recent one, it's got the ribbon with the file menu and all menu headings are capitalized.
Here's a formula you can use (note: enter this as an array):
=IFERROR(INDEX(A$1:A$200,SMALL(IF(C$1:C$200="Fixed",ROW(A$1:A$200)-ROW(A$1)+1),ROWS(A$1:A1))),"")
You may need to tweak the ranges, I think I got them to match yours, but again, probably need to tweak. You can then drag this down, and it'll fill in with the values from column A, skipping any blanks.
Edit: Here's a screenshot to (hopefully) help show what I did:
You can edit the ranges, naturally, to be over two sheets.
To clarify, A$1:A$200 is the range of what you want to return (the index). C$1:C$200 is the range that holds "Fixed".

Excel formula to prevent duplicate name entries

I am creating a work chart for a project with excel table. However with so many people to manage I have ran into an issue of often putting same person twice on different columns of the same row (he/she can't work on two places at same time!)
So, I am looking for help with a formula that notices if the same name appears twice on a row but does not count multiple blank cells as duplicates. My understanding of excel is very basic and so far I have managed to get this far
=COUNTIF(A6:W6;A6:W6)=1
which returns to me with false, which I assume is because of the blank, unfilled cells still within the table being counted as duplicates.
Help would be appreciated, thanks.
You can't have a range as the second argument of a Countif. The range you pass into the formula will resolve to just the first value. Use the Evaluate Formula tool to see what I mean.
If you want to determine if ANY name in the range A1:W1 appears more than once (and exclude blanks), you will need a recursive function. That can only be done with VBA, not with a formula.
You could use a Countif in a conditional format to highlight duplicate names in a row. That's a piece of cake. Pipe up if you want to do that.

Resources