Excel Fill Single Values in a Different Column using IF AND functions? - excel

I have a table that somewhat looks like this:
I am trying to spread the values on column B using an IF-AND function so that it would pull the values from column A until it reaches a new value in the column.
I have tried =IF(AND(A2="",A3="",A1<>""),A1,A2) for cell A2, but while the function recognizes the beginning of a new value, it ends up in 0s all in between.
How should I adjust the function to be able to fill the cells with corresponding values? I appreciate the help.

If you're willing to enter a value in B1 by hand, starting in B2 you can use:
=IF(A2="",B1,A2)
If not, and if you don't mind using a volatile* formula, starting in B1 you can use:
=IF(A1="",OFFSET(A1,-1,1),A1)
*Note: a volatile formula is one which causes an entire workbook to recalculate whenever any change is made. This can significantly slow down a workbook.

The adjusted formula is =IF(A2="",B1,A2). It basically pulls the value from above if the cell to the left is empty, and if it isn't empty, it pulls the value from the cell to the left.
The corrected formula

Related

Excel - Double press of the Fill Handle is filling to the end of column, not the end of adjacent dataset

Summary:
I am currently trying to fill a formula to a whole column in Excel to the end of an adjacent dataset (A2:A14500). Instead of the usual behaviour where Excel will flash-fill it to the end of the dataset in the adjacent column B2:B14500 for example, it instead flash fills it to the whole column (B2:B1048576), even past the end of the dataset in column A.
Use Case:
Column A is just a =FILTER command to pull from another sheet, excluding the blanks (in my live sheet, cell A1 is =FILTER('Raw'!A:A,'Raw'!A:A<>""). All other columns contain headers in cell 1:1. Cell B2 contains a basic 2 part =IF statement with an error catchall: =IF(ISERROR(VLOOKUP(A2,'Lookup'!A:B,2,FALSE)),"No",IF(VLOOKUP(A2,'Lookup'!A:B,2,FALSE)="Error","Yes","No"))
In my current example, the =FILTER in column A produces 14500 rows of data. I am attempting to use the fill handle to populate B3:B14500 with the =IF statement currently in cell B2. When I double press the fill handle, it fills the whole column of B3:B1048576, which causes Excel to crash (I am trying to do the same for 32 columns (B2:AG14500), so it is flash-filling over 33 million formulas instead of 600K).
Expected result when double clicking flash handle in formula column:
Data
Formula
1
Yes
2
Yes
3
No
4
Yes
Actual current result when double clicking flash handle in formula column:
Data
Formula
1
Yes
2
Yes
3
No
4
Yes
No
No
No
No
No
Final Comment:
Usually, when double pressing the fill handle on a formula in column B, I'd expect it to match the end of the dataset in column A (If column A contains data in cells A2:A100, I'd expect double pressing a formula in cell B2 to copy that formula to B2:B100, not B2:B1048576).
I know that copy-pasting is an option, as is manually dragging the fill handle down, but this involves me using weird Ctrl/Shift/Arrowkey combos to select the right range (this is supposed to be user friendly by others who don't use Excel much), or a long time holding the fill handle as there's 14K rows of data. Additionally, I am aware of Home>Fill>Down and Data>Flash Fill but neither of these work for me (Fill Down replaces the formula in B2 with the header in B1 and only copies down to B2, and Flash Fill tells me it can't see a pattern, despite providing it 1/2/5/10 cells of example data).
Any assistance with understanding why the double-click fill handle isn't working (I suspect it's due to the way it handles the =FILTER in column A), or how to overcome this would be appreciated. Currently using MSO365. Thanks!
PS. The reason I haven't filled the formulas manually is the number of cells in column A will change for each report generated with this spreadsheet, so the number of cells it needs to populate will vary.
=IF(ISERROR(VLOOKUP(A2#,'Lookup'!A:B,2,FALSE)),"No",IF(VLOOKUP(A2#,'Lookup'!A:B,2,FALSE)="Error","Yes","No"))
Adding # to the cell range that results in the spill will reference the whole spill. In case of lookup it'll spill the result of the lookups from the first to the last of the cells from the spill range.
PS since you own Office 365 you might want to look into XLOOKUP instead of VLOOKUP. XLOOKUP already has an embedded value if not found.

Incrementing a column number within formula

Here is my formula:
{=MAX(ROW($1:$120)*(Table1[results1518]=1))}
so far I have done 1518 cells manually as indicated by the results#.
I have about 2000 more cells to go. The table is on one sheet and this formula in each cell on another.
I need to find a way to increment the results# from one cell down to the next cell below it and so on down the column on the second sheet.
I would make a helper column that listed all the result# you needed to cycle through. You can either use excel's auto fill ability or just add 1 to the value of cell in the row above. For example, A3=A2+1.
Next create a second helper column that returned a text value embeding that number. B2 would look something like this ="Table1[results"&A2&"]"
Finally, you can use Excel's indriect formula looks up the value specified by the second helper column. {=MAX(ROW($1:$120)*(INDIRECT(B2)=1))}
There are probabally more effecient methoods, but without knowing more about your setup, this is what I've got.

Transferring certain cells from one sheet to another in excel despite column/row insertion/extraction

The title pretty much says it. I need to transfer certain cells from one cell to another without the coordinates of the cells changing after an insert operation.
In ex., I want the value of cell B3 of Sheet1 to transfer to cell A2 of Sheet2. If I insert a column on the left of B3, the previous B3 will become C3 and you now have a new B3 in which you can add a new value. I want my A2 to still receive the value of B3, but the new B3, not the old B3 with is now C3.
If I go with +Sheet1!B3, after the insertion of the column it will become +Sheet1!C3. I want it to remain to +Sheet1!B3.
I tried with $, +Sheet1!$B$3, but it still changes.
You can use the indirect function in excel.
+INDIRECT("Sheet1!B3")
With the caveat that you never change the location of column A you could do the following:
=INDEX(Sheet1!$A:$$ZZ,ROW(B3),2)
Caveat: as set up will only work for cells between and including columns A and ZZ. the ZZ reference will increase as columns get added. If you have columns outside of ZZ initially, then you will have to adjust the final column reference to suit your needs.
INDEX gave me some errors in the function (probably on my end), but I managed to solve it using INDIRECT.
Ty for the feedback, #AlexCollins #ForwardEd

Expanding an Excel formula without referencing the previous cell

I am attempting to use an IF statement to check whether the sum of two cells from another Excel sheet is greater than or equal to 1.
For a sheet called Test1 with the values of interest in column C, this is what I have so far, which works fine:
=IF((Test1!C1+Test1!C2>=1),1,0)
In column B on a second sheet that I'll call Test2, I want to copy this formula down 200,000 rows. However, if the aforementioned formula is in cell B1, for the formula in B2 I would like the formula to read:
=IF((Test1!C3+Test1!C4>=1),1,0)
I want to copy the formula down the column so that the second cell reference in the formula in the first row does not become the first cell reference in the formula in the second row (eg. it would go C1+C2, then C3+C4, C5+C6, etc.).
I have tried manually entering the formula for a few rows, highlighting those, and copying them down but can't get the desired cell reference pattern. If I highlight and drag these first three formulae down another three rows, C4 and C5 are repeated and not in the correct pair.
=IF((Test1!C1+Test1!C2>=1),1,0)
=IF((Test1!C3+Test1!C4>=1),1,0)
=IF((Test1!C5+Test1!C6>=1),1,0)
=IF((Test1!C4+Test1!C5>=1),1,0)
=IF((Test1!C6+Test1!C7>=1),1,0)
=IF((Test1!C8+Test1!C9>=1),1,0)
I have tried using OFFSET() within this formula but couldn't get it to work. I am basically just wanting to add 1 to each of the cell references in the formula, as compared to the previous row (but not to actually add 1 to the value of that cell, as would happen with C1+1 for example).
Any insight would be greatly appreciated!
If you plan on copying this down 200K rows then you will want the absolute simplest formula that accomplishes the stagger. Avoid the volatile OFFSET function or be prepared to spend a lot of time waiting for random calculation cycles to complete. A volatile function will recalculate whenever anything in the workbook changes; not just when something changes that involved the formula in the cell.
=--(SUM(INDEX(Test1!C:C, (ROW(1:1)-1)*2+1), INDEX(Test1!C:C, (ROW(1:1)-1)*2+2))>=1)
The following formula should do the trick:
=(SUM(INDIRECT("C"&ROW()*2-1);INDIRECT("C"&ROW()*2))>=1)*1
And that's the version using IF:
=IF(SUM(INDIRECT("C"&ZEILE()*2-1);INDIRECT("C"&ROW()*2))>=1;1;0)
You say I am basically just wanting to add '1' to each of the cell references in the formula but appear to be incrementing by 2, so I am confused but an option might be to apply you existing formula to 400,000 rows, together with =ISODD(ROW()) in another column, then filter on that other column to select and delete those showing FALSE.
Excel's autofill won't do the 2-cell shift that you're looking for. You can use the functionality that is there.
Put =IF((Test1!C1+Test1!C2>=1),1,0) in the top cell and drag a copy to the second row (it will be =IF((Test1!C2+Test1!C3>=1),1,0) but that's okay). Now, put 'A' and 'B' in the next column. Select all 4 cells and copy them down 400k rows.
Use filter to delete rows flagged with 'B' and delete the blank rows.
(Select blank rows with [F5] click Special and select Blanks, then right-click and delete)
Here is all you need. It's fast and nonvolatile.
=--(SUM(INDEX(Test1!C:C,ROW(1:1)*2-2):INDEX(Test1!C:C,ROW(2:2)*2-2))>=1)
Copy it down as far as you like.

Excel Formula Referencing

quick excel question:
If I put values in cell B1 and B2.
Then write the following formula in cell A1:
=$B$1-$B$2
then I highlight cells B1 and B2 and move them to column C. the formula in A1 automatically adjusts for the move ie. formula now becomes:
=$C$1-$C$2
How would I get it to stick to column B and not switch to column C. I tried searching google but did not get right answers (probably am not phrasing question correctly).
The context of my problem is that formulas in one sheet are being calculated based on month end data which is placed in another sheet. Now I need to add April month end data. So I shift the old data to the right and input April's data, but the formulas are automatically adjusting for the shift and still refer to March's month-end data. This despite the formulas using absolute referencing.
Thanks for any help provided
The formula you are looking for is
=INDIRECT("B1")-INDIRECT("B2")
This will always refer to Cells B1 and B2 regardless of what you to do move the cells or add new columns etc.
This will allow you to simply insert a column for the new month.
Not a good spreadsheet design, you should really add new data to a new column.
However, if you are determined to stick to that design, copy and paste the old values to a new column, then delete the originals. Formulas will not be alterd by that.

Resources