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).
Related
Let's say I have a simplified table of only 2 columns. Column one is Group number, with groups of different sizes. Column 2 is also numbered but has a lot of blanks.
I basically want to fill these blanks with the next NOT blank, if it is still in the same first-column-group.
I don't know if it works to show a table here, but this is what it is now and what I want to achieve with a simplified dataset:
What I tried is to use an If function. First, it checks if B1 is blank. If it is blank, I want it to check if A1 is the same "group" value as A2. If that is also true, then I want the formula to return me the value of B2. However, if B2 is also blank I want it to loop: Check if A1/A2 are the same as A3, and then give the value of B3. And continue. Plus! If B1 is not blank to begin with it just needs to return the value B1. And if B1 is blank but A1 is not the same group as A2, I want it to remain blank (or 0 is also fine).
The only way I did this was making an extremely nested if function that kept repeating for the [if true] part, which looks like this:
=IF(B2="";(IF(A2=A3;
(IF(B3="";(IF(A3=A4;
(IF(B4="";(IF(A4=A5;
(IF(B5="";(IF(A5=A6;
(IF(B6="";(IF(A6=A7;
(IF(B7="";(IF(A7=A8;
(IF(B8="";(IF(A8=A9;"xx";""))
;B8));""));B7));""));B6));""));B5));""));B4));""));B3));""));B2)
However, sometimes there are 100+ blanks within one group, and I'm trying to avoid looping 100+ repetitions of that formula.Right now, when there are not enough loops for within a group, it shows the xx. Is there no way to just replace the B1 by a continuous string of cells of column B? I looked at the Row function but it only works when you pull it down if I understand it correctly.
Would really appreciate the help!
If you did want to try a formula, something like this will work:
=IF(B2<>"",B2,IFERROR(INDEX(B2:B$19,MATCH(A2,IF(B2:B$19<>"",A2:A$19),0)),""))
entered as an array formula using CtrlShiftEnter in my version of Excel (2019).
The inner IF statement produces an array where only the rows that have a number in column B will have a value equal to the group value in column A, otherwise it will default to FALSE, so you get
False
False
1
False
1
False
False
2
False
...
then you do a Match on the value of A which is in the current row in the array to find the next row where there is a non-blank value in column B (3 in the first case). Then Index produces the corresponding value from column B in the row found by the Match (1 in the first case).
If the match fails because there are no further entries in the current group (like in rows 15 and 16 of the screenshot) then it will call in the "" from the IFERROR statement, so you get a blank in that row.
You could change the IFERROR to zero if you preferred to have zeroes in those cells rather than blanks:
=IF(B2<>"",B2,IFERROR(INDEX(B2:B$19,MATCH(A2,IF(B2:B$19<>"",A2:A$19),0)),0))
I am trying to figure an Excel formula and Google is not helping.
I almost have what I am trying to do, but need a 'dummy' column where I do the math in the column cells.
What this means:
1) What I have working:
Cell A1, with math formula (I wish to delete this 'dummy' cell and incorporate this into the formula in Cell B1, see further explanation below)
=SUM((6.75*1)+(5.73*2)+3)
Cell B1, with value from Cell A1 but limited to an integer less than or equal to 80
=IF(SUM(A1)>80, 80, SUM(A1))
Cell C1, with a value looking at Cell B1 and entering in this cell either 0 or any integer greater than 80
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: This works perfectly, I change any values in the Cell A1 formula and it correctly reflects in Cells B1 & C1.
2) The missing piece:
I would like to combine the two formulas above in cells A1 & B1 into one cell, and still have the same results described above for each of the cells.
To articulate this another way is:
have a cell with a math formula,
calculate the results of that formula, and then,
enter back in the same cell that formulas results,
with the condition of 'less than or equal to 80'
while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of the first cell.
As an example:
Using only Cells A1 and B1 in a spreadsheet, and combining the above working formulas (which do not work for me in Excel), it would look like this:
Cell A1:
=IF(SUM((6.75*10)+(5.73*7)+8.5)>80, 80, SUM(B21))
Note: Cell A1 formula from above, =SUM((6.75*1)+(5.73*2)+3), combined with Cell B1 formula from above, =IF(SUM(A1)>80, 80, SUM(A1)) (with the Cell A1 formula replacing both 'A1' values in the Cell B1 formula).
Cell B1:
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: Identical to the Cell C1 formula above.
Is it possible to do this, calculate the results of a cell's formula, while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of that first cell?
I realize writing this out, it's more complicated than I originally anticipated, which explains why Google wasn't getting me anywhere.
Thanks for any hints.
Phil
Strictly speaking, this is not possible. A cell has only 1 value and that is the result of all calculations. The IF statement is not hiding the value of the cell. It is changing the value.
A formula to another cell can only use the final value of the cell. It can't extract part of the formula in the other cell. There's no way for Excel to know which part to extract, even if there's only a single calculation in an IF statement.
That said, there is a different workaround possible in your case... and that is to change how your value is displayed through custom formatting. Formulas change the value of cells, whereas formatting changes how those values are displayed.
Place your formula in cell A1: =6.75*10+5.73*7+3
Right click on cell A1 and select Format Cells...
Make sure you're on the Number Tab
In the Category column, select Custom
Enter this formula in the Type box: [>80]"80";[<=80]General
Enter this formula in B1:=IF(A1>80,A1-80,0)
Check that the number format of B1 is still "General" or "Number"
The result is A1 has calculated and stored the actual value, but displays the text string "80" if it's value is above 80. You can then use the actual value from A1 in other formulas.
NOTE: This type of custom formatting is extremely poor practice as it can become very confusing and very error prone. The value of the cell is different to what it is showing and if other users are unaware, creating new formulas referring to the affected cell can unwittingly produce incorrect and/or unexpected results.
In particular, Excel tries to be helpful and can automatically copy the formatting from one cell to another if it is next to the original cell or if it refers to only the original cell in a basic formula. Copying and pasting also copies the formatting by default. Unintentionally copying the formatting to other cells will also alter how they appear.
Also note that you don't need to put SUM() around a formula that already had the addition operators included; and Excel uses order of operations so you don't need the brackets to do multiplication before addition.
Lastly, you could also just use =MAX(A1-80,0) in B1.
I am running into an issue in Excel when trying to create an automated spreadsheet. I have most of the data ready to go already, but this one thing is giving me some serious trouble.
I am trying to create a data tracking file. Most data will be entered manually, in which I will have certain data to be tracked (column A) and criteria to track that data for (row 1). The data to be tracked will always be the same, but the criteria will be changed depending on the needed numbers. The same sheet will contain multiple sets of this one table to track the same data over different time periods.
I would like to make entering the criteria for all tables easier, by having Excel automatically copy the contents of row 1 into the header rows of the other tables if data is present in row 1. If a cell is blank in row 1, I would like the corresponding cells in the other tables to also be blank.
I thought there was a way to do that, but I can't remember how. Also, I would like to achieve this without using macros.
I have been searching here and elsewhere online, but all I could find were ways to display pre-determined text or values, if a cell contains specific text, i.e. "if cell x contains apple, return TRUE in cell y" or "if cell x contains apple, sum value of cell y in cell z".
Example:
IF B1 =/= empty THEN B14=B1; IF B1=empty THEN B14=empty
Right now the only option I found was the formula =B1 in B14, but that returns a 0 if B1 does not contain anything, I would like to have B14 empty though in that case.
Is what I am trying to do at all possible, or am I remembering this wrong?
Any help would be really appreciated.
Try the following formula in cell B14:
=IF(B1<>"",B14,"")
The "" in the formula represents blank while <> represents 'is not equal to'. So IF B1 'is not equal to blank', THEN return B14. Otherwise (IF B1 'is equal to blank'), return blank.
You can as well reverse the TRUE/FALSE values of the IF by using:
=IF(B1="","",B14)
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.
How would I go about implementing a macro or conditional formatting rule that would compare two separate sheets based on their values in a column?
Basically, what I need to do is search each sheet for the matching values (e.g. cell A10 would be "project 10" and on the other sheet it might be cell A6 as "project 10").
Then it would look at a separate column, and match the dates there (i.e, cell A10 would have date "11/12/15" and cell A6 on the other sheet would have a date of "11/11/15") highlighting the cell if it is different than the date on the first sheet.
The tricky thing here is that the projects are in a different order on each sheet (as explained above). I have attempted several code suggestions but have not gotten anywhere yet.
Let's solve using conditional formatting.
As you may be aware, conditional formatting works by setting up a rule which governs the cell you apply it to. If that rule produces TRUE, then the rule is applied (diff colour, etc). So the goal here is to make a formula which results in TRUE when all of your conditions are met. There are two conditions we care about here. First, does the item in column A on sheet1 exist in column A on sheet2?
=not(iserror(match($A1,sheet2!$A:$A,0)))
First, it uses the MATCH function to check if A1 (with an absolute reference on the column, so that as you apply the rule to columns A & B it will not look at column B at all) exists on sheet2 columnA. If it does exist, it will spit out the row number that it appears at. If it does not exist, it will create an error. So that is wrapped in ISERROR which says "if this argument returns an error, spit out TRUE". But, we want it to return TRUE when there is no error. So, we wrap that in NOT, which reverses TRUE to FALSE, and vice versa.
Now what you actually care about is, if A1 exists in sheet2, then does that row in column B on sheet2 match the value in B1 on sheet1?
So we find the value in column B, where there is a match in column A, by using the index function, like so:
=Index(sheet2!$B:$B,match($A1,sheet2!$A:$A,0))
This gives that value from column B in sheet 2. So, check: does that value equal the value in B1, sheet1? [We actually check to see if that value is DIFFERENT than B1, so we use "<>" instead of "=".
=Index(sheet2!$B:$B,match($A1,sheet2!$A:$A,0))<>$B1
Now we just need to replace an error (if Match returns no match) with "".
=Iferror(Index(sheet2!$B:$B,match($A1,sheet2!$A:$A,0)),"")<>$B1
And that's it. If there's a match in sheet2 columnA [using the MATCH function] it gives you the date from column B [using the INDEX] function. If there's no match, it returns "" [using the IFERROR function]. And then if that value does NOT equal B1, then it results in TRUE, which triggers your conditional formatting.