How to fix search to header cell? - excel

I have a table like this:
Name
Response
Thursday
A
Monday, Thursday
Yes
B
Tuesday
No
C
Wednesday
No
This is an output of a Google Form response that I use to collect data, In Column C, every cell contains this formula:
=IF(ISNUMBER(SEARCH("Thursday",B2)),"Yes","")
To populate the "Yes". However, its quite cumbersome to replicate this if I want change "Thursday" to something else. When I try to insert it as C1, as I populate down the cells, it auto increment to C1,C2,C3 etc.
Is there a way to fix the formulate to
=IF(ISNUMBER(SEARCH(C1,B2)),"Yes","")
Across all cells and just have B2 increment?
Thanks!

The cell reference that you are using, such as C1, is relative to the formula position. So when you copy the formula one row down, C1 becomes C2 and so on.
To prevent this you need to make the row and or column address absolute so that C1 remains C1 when the formula is copied somewhere else. To make a row or column absolute, precede the row and or column by the character $. To keep the row absolute, you would use C$1 instead of C1. The key F4 will help cycle through the option when the cell address is selected in the formula.

Related

MS Excel: How do I make cell references variable?

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.

Excel Drag to increment sheet name between file

how to drag to increment the excel sheet from different file?
eg,
Cell A1 =+'[filename]59'!J6
Cell B1 =+'[filename]60'!J6
Cell C1 =+'[filename]61'!J6
i tried this now
=INDIRECT("SHEET"&COLUMN()-1&"!J6")
and readjust all the name etc, and now i wanna drag down and increment the cell to J7,J8,J9 etc
how do i do it?
Help please
Try =INDIRECT("SHEET"&COLUMN()-1&"!J"&ROW()). ROW() returns your current row. So, if you write =ROW() in A15, you'll get 15. Good for dragging down :)
If you want to change the value so that it matches a row different from your current row, you'll need to add or subtract from ROW(). So, if you wanted to put this in some cell B2 or C2 and have it match up to J5, you'd have to add 3. That would work like this:
=INDIRECT("SHEET"&COLUMN()-1&"!J"&(ROW()+3))
Obviously, you should change the 3 to whatever adjustment value you need.

Insert rows into excel range via formulae

I have the following range in column A :
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Sep-13
In column B, I would like the same list of dates ( i.e. March 12 -> Sep 13), but I would like every August to be duplicated:
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Aug-13
01-Sep-13
I can add as many columns in between as I like, but it must be done with formulae.
I'm having a little trouble figuring this out - any help would be much appreciated.
A formula is not capable of inserting rows.
Copy ColumnA to ColumnB, insert a cell and shift down immediately under each Aug and in the blanks created enter:
=R[-1]C
This formula works, assuming the values in column A are unique. Paste the formula into cell B3.
=IF(AND(MONTH(B2)=8,MONTH(B1)<>8),B2,INDEX(A:A,MATCH(B2,A:A,0)+1))
The current formula assumes that B1 and B2 are part of the list in column B. You'll have to manually fill in the values for B1 and B2 unless you change the formula a little.
What the formula does:
If B2 is August and B1 is not, then B3 copies the value of B2.
Otherwise B3 is the date in Column A found under the date B2.
You can then copy the formula into the remaining cells below B3.

Sum only matched values from two columns

Hello Everyone,
Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.
Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that's why I need to sum the hours (20+10=30) from column B by it's month below.
I also attached the example excel sheet below.
https://www.dropbox.com/s/0s51g1i8g6s6e2d/Test.xls?m
Thanks in advance. :-)
You could get complicated with customer functions but if having an extra column (potentially hidden) doesn't matter then this would work:
In cell D2 enter:
=iferror(vlookup($A2,$E$2:$E$20,1,FALSE),"x")
Drag the formula down.
Under each month you can then put:
=sumifs($B$2:$B$16,$C$2:$C$16,B$22,$D$2:$D$16,"<>x")
Drag the formula across
This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.
Written on the fly and not tested so excuse any minor errors...
Both answers posted thus far are just fine, but just as an alternative, here's what I would do. Put this formula in cell D2 and drag it down:
=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")
Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, ..., July, you can put this formula into H2 and drag it down:
=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)
That should get what you want.
Put this formula in Cell D2 and drag down:
=IF(NOT(ISERROR(MATCH(A2,$E$2:$E$20,FALSE))),B2,"")
In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.
Then, in Cell B23, put this formula and drag it across:
=SUMIF($C$2:$C$16,B22,$D$2:$D$16)
(I put the formula in row 24 to check against the data you already had in Row 23)
Shouldn't be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across
=SUMPRODUCT(SUMIFS($B2:$B16,$C2:$C16,B22,$A2:$A16,$E2:$E20))

How to reference value in cell to the left within a formula

I have 2 sheets in my spreadsheet. Sheet2 pulls information from Sheet1. In sheet2, there are 2 columns. Column A has company names. Column B has a formula which searches for the company name of that row within sheet1, and sums the values from that row in sheet1.
I have been able to achieve this with the following formula.
=SUMPRODUCT((Sheet1!B:B=A1)*(Sheet1!F:F))
This works fine, however I have to manually type "A1" into the formula. For the other rows, I would have to write B1, C1, D1 etc.
I have searched for how to reference the cell to the left, and I found this formula...
=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())), 0, -1)
This seems to work as a standalone formula in a cell, but I cannot figure out how to incorporate this into the SUMPRODUCT formula. Anything I try gives errors. I need something like this.
=SUMPRODUCT((Sheet1!B:B=(=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())), 0, -1)))*(Sheet1!F:F))
As per pnuts' suggestion to make it an answer:
The answer is just to drag the formula around. Just make sure to fix (either use F4 or add dollar signs) your range if it is not an entire column or an entire row

Resources