I probably didn't word that title correctly, so let me explain what I'm trying to do.
I need to find cycles in a series of data. So let’s say I have all of my data in column A of an Excel spreadsheet. If a condition that I’m looking for is true in, say, cell A7, I want to check to check if it’s true in every second cell (A9, A11, A13 and so forth). If it’s not true in every second cell, I want to adjust the model to check every third cell starting with that A7 cell (A10, A13, A16, and so on). If the condition is not true in every third cell, then I want to check every fourth cell (A11, A15, A19, etc.).
Programming the formula to check if the condition is true should be somewhat easy using either IF or AND formulas. My problem is how do I change the model to switch from every second cell to every third cell, and then run it to check every fourth cell, and so on. I’d like to, say, set up the formulas in column B and have cell C1 be a user input that determines which cells are used in the formulas in column B. Is there a way to do this?
Example: if cell C1 says “2”, then the formulas in column B check every other cell in column A, and if I change the value in cell C1 from “2” to “3”, then the formulas in column B switch from checking every second cell to checking every third cell and report back to me.
I could just manually change the cell references in the formulas in column B, but that could take bloody ages and I figure there’s got to be a better way.
So I’m looking to make the cell references ‘variable’ in a sense. Instead of hardcoding the cell references and saying “look at cell A7, then look at cell A9, then look at cell A11…” I want to tell Excel “look at A7, then the next cell you look at is dependent upon what I say in cell C1.”
The image below shows my setup:
I have simple data in column A. Column B determines whether the formula in C should be evaluated. For example, B2 contains the following formula:
=IF(MOD(ROW(A2),$D$2)=0,1,0)
Column C would contain the logic you want to apply. In this case, I return the data in A if B is 1; otherwise, I return "":
=IF(B2=1,A2,"")
Column D determines the number of rows to skip.
If you want just one column, this formula would go in B1 and you can drag it down. Update the $A$1:$A$20 range to include your entire range. This formula will check whether the previous cell in your cycle (every 2,3,4,etc) matches.
=IF(AND(ROW()>$C$1,MOD(ROW(),$C$1)=0),INDEX($A$1:$A$20,ROW()-$C$1)=$A1,"")
Do not use INDIRECT...ever.
Related
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))
I'm wondering how I can fill multiple cells (non-consecutive) in a single row with a single input.
So for instance I would like to be able to type in a 1 in cell A1 and then have cell B1 be filled in with a value and then cell D1 be filled in with another value.
Then when I type in a 2 in cell A2, it will fill in cell C2 with one value and E2 with another.
So basically there are certain pre-packaged values that I would like to be filled in and it would be nice to do that just by typing in a number instead of going through individually and filling all of them in
Are the values in cells A1, B1 and D1 related by a mathematical form? There is one way this can be done but not sure if this is what you are looking for.
Source(https://www.howtogeek.com/279148/how-to-automatically-fill-sequential-data-into-excel-with-the-fill-handle/)
To skip a column when filling a linear series, enter the first number in the first cell and then select that cell and one adjacent cell (for example, the next cell in the next column).Then, drag the fill handle across until you fill the desired number of cells. More details are available in the above link.
I wish to check if a cell in say column A is empty and if it is then move the data from the next column B into it. Else nothing done.
I wish it to check 1500 rows. I tried
If(A2="",A2=B2,"") I thought I could just copy it down the column. I get a circular error reference and also then cellA2 changes to 0.
Thank you for your help.
Is this a one-time task, merging two columns of data, or something that needs to be run repeatedly?
Your formula won't work (partly) because you can't have a cell that contains both a value and a formula (to check that value), at the same time.
You could, however have a 3rd column that equals Column A, unless Column A is blank, in which case it looks at Column B.
With your example, in cell C2 you could put:
=If(A2="",B2,A2)
With your formula above, you're trying assign a value to A2 with A2=B2. Excel formulas in cells assign values to "themselves" and cannot directly affect other cells.
A formula in A2 can only affect the A2. (However, the value of a cell can indirectly affect other cells with the help of VBA or features like Conditional Formatting.)
The reason your If statement isn't giving you an error with A2=B2 is because that statement A2=B2 is comparing the value of cell A2 to B2 and returning TRUE if the cells match, and FALSE if they do not (so will always return FALSE in this case).
I want a cell to display a value from a list elsewhere in my sheet.
The user inputs a value lets say 50 in cell A1. in that case i want cell B1 to display the value given in cell X50.
when the user enters a 61 in cell A2 i want B2 to display the value of X61
When knowing the column and sheet using the nonvolatile INDEX() function is an advantage.
Indirect is a volatile function, meaning that it recomputes every time excel recomputes whether the data for which it refers changed or not. If the workbook is filled with indirect function it will slow down the computation time.
The following INDEX Formula will only recompute when the data to which it refers changes.
In B1 put:
=INDEX(X:X,A1)
Then copy down the desired number of rows. The A1 will change To A2 and so forth.
This is possible with use of INDIRECT()... How can you use it? Simply do this
Type the following in you cell B1:
=INDIRECT("X"&A1)
And in you B2 type this:
=INDIRECT("X"&A2)
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.