Fill Excel column from every 13th row - excel

I need to fill a column in Sheet1 starting on G112 from Sheet4 starting from D2.
So Sheet1 G112 =Sheet4!D2
G113 would have =Sheet4!D15
and so on. I also need every 13th row from other columns as well and I don't want to have to copy the reference for every cell I need. Is there a way to fill a column with every 13th row so I don't need to do it manually?

You can use this:
=INDIRECT("Sheet4!A"&((ROW()-112)*13)+2)
Note: This formula works only of the cell you're inputting it the first time is in row 112. You'll have to adjust it otherwise here:
=INDIRECT("Sheet4!A"&((ROW()-112)*13)+2)
^^^
To adjust the rows to skip each time, adjust here:
=INDIRECT("Sheet4!A"&((ROW()-112)*13)+2)
^^
And to adjust the offset from the beginning (which is a minimum of 1, otherwise you'll get a reference of A0), adjust here:
=INDIRECT("Sheet4!A"&((ROW()-112)*13)+2)
^

Try the INDIRECT function:
If B1 contains INDIRECT("A" & C1) and C1 contains 6, B1 will show the value of the A6 cell. Using that function, you can put the desired indexes in a column (e.g. C), and extract the values from another column (e.g. A).

Related

Excel - Offset to last non-blank cell

From my research, when a bunch of cells are merged, you can only reference the first row and first column of the merged cells. EG. if A1:A3 are merged, then I can only access the data using A1 only, and A2 and A3 returns 0.
Now let's say I have a column B that has a formula that calculates based on values in column A. If I drag this formula down, then B2 and B3 will end up using value of 0, when they should be using value in A1.
Effectively, what i want to do is "if the cell in column A (of this row) is blank, then use the last non-blank value going upwards".
I know this will need to combine a couple of formulas, but I can't figure out how to create this. For a start, I can use the Offset function to "go up", but the difficult part here is how to find the previous non-blank cell?
I also tried combing OFFSET with COUNTA (see https://www.exceltip.com/other-qa-formulas/get-the-value-of-the-last-non-blank-cell-in-a-column-in-microsoft-excel.html), but this doesn't work if this occurs multiple times.
Easiest way is to use a helper column:
In B2 write
=IF(NOT(ISBLANK(A2)),0,B1+1)
and in C2 write
=OFFSET(A2,-B2,0)
Edit: actually... the solution without helper column is even easier! Write in B2:
=IF(ISBLANK(A2),B1,A2)
To avoid the helper column, you can use the INDEX + AGGREGATE functions:
=INDEX($A$1:A1,AGGREGATE(14,6,($A$1:A1<>"")*ROW($A$1:A1),1))

Excel function that copies rows if they fall within the range of 2 dates

So at the top of my Excel sheet I have 2 cells, A2 and B2, where people can enter a starting and ending date.
On a seperate sheet I have an enormous list of starting and ending dates in columns A and B, and corresponding data for each of these 'events' in columns D through G. I need my function to copy all rows where the starting date falls between the two specified dates, and copy the data to the first sheet, in cells A4 - G4 through A100 - G100. (I just chose 100 as a large number, to make sure the area where the data gets placed is large enough)
I'm guessing this function I need includes the INDEX function, but I only know how to use it to look up one data cell at a time, not how to copy an entire range of cells.
Can anyone help?
No helper columns required.
Enter this formula into cell A4:
=IFERROR(INDEX(data!D$2:D$9999,SMALL(IF((data!$A$2:$A$9999>=$A$2)*(data!$A$2:$A$9999<=$B$2),ROW(data!$D$2:$D$9999),9E+99),ROW(1:1))-1),"")
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Now copy the formula to the range B4:D4.
Now copy the A4:D4 to the range A5:D100.
That's it.
Let's say Column C in the data sheet is blank, and free to add a formula.
Let's also assume that the data begins in row 2.
Then the following formula can be put in C2 & copied down:
=IF(AND(A2>=Sheet1!$A$2,B2<=Sheet1!$B$2),C1+1,C1)
Basically it is saying that if the beginning date of the current record is greater than or equal to the date the user is looking for, and the ending date is likewise within range, iterate the record, otherwise not.
At this point the user sheet can have a simple VlookUp as follows:
In D1: =VLOOKUP(ROW($A1),Sheet2!$C:$G,COLUMN(B$1),0)
Copy this across to G and down however many rows you like.

Formula to select row cells starting from a certain cell

Is there a way to include in a formula the sum of the values of a row, but starting from a certain cell onto the rest of the row?
Something like =SUM(C5:~)?
A formula's cell range generally has two parts. A5:H5 contains the cells starting at A5 and includes all cells going across row 5 to H5. Similarly, A5:A9 contains the cells starting at A5 and includes all cells going down the column to A9.
You can use the INDEX function to determine the second part of the cell range reference.
'from A5 to the last number or date in row 5
=A5:INDEX(5:5, match(1e99, 5:5))
'from A5 to the last text in row 5
=A5:INDEX(5:5, match("zzz", 5:5))
'from A5 to the last number or date in column A
=A5:INDEX(A:A, match(1e99, A:A))
'from A5 to the last text in column A
=A5:INDEX(A:A, match("zzz", A:A))
To SUM from D5 to the last number in row 5,
=SUM(D5:INDEX(5:5, match(1e99, 5:5)))
This method is preferred when creating dynamic named ranged (with formulas as the Refers to:) over the OFFSET function as INDEX is non-volatile while OFFSET is volatile and will recalculate whenever anything in your workbook changes.
=SUM(C5:XFD5)
Tested and it works. The last column is XFD, so you're summing on everything right of C5.
This would work:
=SUM(5:5)-SUM(A5:B5)
as would
=SUM(C5:XFD5)
as XFD (16384) corresponds to the maximum number of columns.
try this:
=SUM(E3:E)enter image description here
so the result will be 6, as you starter from
certain cell.

Find the first empty cell in the same column/row

I am trying to work out a formula that will give me the row number of the first empty cell in a column. Currently I am using:
=MATCH(TRUE, INDEX(ISBLANK(A:A), 0, 0), 0)
This works fine, unless the formula is put in the same column as the column I am searching in, in which case it does some sort of circular reference or something. Is there a formula I can use instead which will work when placed in the same column as it searches in?
Another way to do it
=MIN(IF(A2:A6="",ROW(A2:A6)))
you have to press CTRL+SHIFT+ENTER
The difference is that this will give you the Row number of the first empty cell
The previous answer will give the position (how many rows from the starting row) of the first empty cell... Both ways are valid depending on your needs
All you have to do is count the non blank cells in a column : COUNTA
e.g.
=COUNTA(E:E)
If you want to find the first blank cell from further down the column, then set the column range e.g. E23:E100 and add the cell number -1 to it.
=COUNTA(e23:E1000)+23-1
=MATCH(TRUE,INDEX(ISBLANK(INDIRECT("R[1]C:R1048576C",0)),0,0),0)+ROW()
This formula above returns the row number of the first blank cell in the current column and below the current row, but it does not need to be entered in row 1 of the worksheet.It replaces the A:A target range with a range that starts in the next row and continues to the end of the sheet and then adds the current row number to the result to add the skipped rows back in. This avoids the circular reference since it starts on the next row.
Using the INDIRECT(ref_text, [a1]) function with the second argument set to FALSE or 0 allows you to pass ref_text in R1C1 notation (eg. B5 as R5C2).
The R1C1 notation also has a lesser known syntax for describing a location as an offset from the current position. If the number following the R or C is enclosed in square braces then it is treated as a +/- offset from the current cell or zero offset if omitted (eg. "R[-1]C[-1]" in cell B5 returns A4 and "RC" in B5 returns itself B5).
The R1C1 location of R[1]C:R1048576C from the formula defines a range starting at the current cell with a RC offset of 1,0 and ending at fixed row 1048576 with a 0 column offset from the current cell. When placed in cell C3 it will be equivalent to C4:C1048576 and in A1 is equivalent to A2:A1048576. If you needed to dynamically set the max row number, you use INDIRECT("R[1]C:R"&ROWS(A:Z)&"C",0) but since current version Excel has a row limit of 1,048,576 it makes sense to just set it.

Conditional format first non-blank cell in multiple rows

Hopefully this will stop the chain.
See the linked questions if you want more background, but I need to conditional format multiple rows (2,000+) from the FIRST (leftmost) non-blank cell + the next 11 columns after it. Not sure if it's needed for the conditional format formula, but I am able to get the start cell for each row, can kind of get the end cell (see below).
Cell address of the first populated cell in the row (*the data starts on row 2, the values begin in column C and end in column P):
{=(ADDRESS(2,COLUMN(INDEX(C2:P2,MATCH(1,IF(C2:P2<>0,IF(C2:P2<>"",1)),0)))))}
^ this gets me an absoluted text-version of the leftmost populated cell in each row. I have all these addresses in a helper column. I am then able to get the desired stopping-point for the format (12th cell to the right of the cell returned from above formula), but I have to manually enter the cell address derived from above formula:
=ADDRESS(2,COLUMN(OFFSET(N2,0,11,1,1)))
I can't nest the start cell formula inside this second formula or it breaks.
THANK YOU!
Desired result (ignore the different colors, they can be the same):
I added a helper column C that finds the first non blank in the row (my data went from column D to column AZ)
=MATCH(TRUE,INDEX((D2:AZ2<>0),0),0)
My conditional format rule applied to D2 to AZ4 was to highlight when the following was true:
==AND(COLUMN(D2)<($C2+11+COLUMN($D2)),COLUMN(D2)>=$C2+COLUMN($C2))
You can modify this to put the helper column where you wish, and to use named ranges.
(Had to add condition to not start coloring before the first instance!)

Resources