How can I use a relative range in an excel function - excel

newbie with advance excel here. :)
I'm looking for a solution how to use dynamic or relative range with the expression I came up with. I have this excel sheet with multiple columns, but I only need to check 4 columns for info. The sheet has like 1000 rows and growing, and I need to go through each row and check for blank cells in each row. Obviously dragging the cell with my formula using the mouse automatically updates the cell reference on the expression. However, I'm going to use the expression in an automation tool where it looks one row at a time and captures the value into another "array" or "collection" variable.
Col A B C D
Student1 7 8 0
Student2 2 1 2
Student3
Student4 1 0 2
Student5
Student6 8 2 4
Student7
Student8 3 1 2
I have this excel expression
=IF(AND(A2 <> "", A3<>"", A4<>""),A1,"empty")
Expected results should be like the below and placed in another Sheet (Same workbook)
Student3
Student5
Student7
Thanks in advance!

Related

Count with criteria for changing column in excel

I have a data looks like this:
a b c
1 3 4
2 3 3
4 1 2
2 4 2
In another worksheet, I want to do the following calculation:
whenever A1 returns a (header of data worksheet), count number of items that are smaller and equal to 2 in column "a". (result will be 2)
if A1 returns b, count number of items that are smaller and equal to 2 in column "b". (result will be 1).
A1 has already been preset with formula such that it will show a or b or c as conditions changed.
I need the formula to be lean... I actually have 6 headers, so if I keep on using if functions, I will probably have to set 6 if functions in one cell...that can be overwhelming. index match cannot provide a range to work on...Any suggestion? thanks
I don't know vba. If you could provide a workable vba code, i don't mind. but i don't know how to read it...>.< please provide user manual for that. lol, thank you~
If your data is found on Sheet1 and the a is found on column a, b is found on column b etc. enter this formula on then next sheet on b1 when a1 is the column value:
=COUNTIF(INDIRECT("Sheet1!"&a1&":"&a1),"<=2")
The Indirect is for adding text to your reference.
If your data sheet is Sheet1, you could try the array formula:-
=SUM((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Must be entered with CtrlShiftEnter
(actually there are 3 items less than or equal to 2 in column A)
Or you can use the SUMPRODUCT version if you prefer not to use an array formula:-
=SUMPRODUCT((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Or you can use this INDEX/MATCH method which is probably more efficient:-
=COUNTIF(INDEX(Sheet1!A2:C5,,MATCH(A1,Sheet1!A1:C1,0)),"<="&2)

Excel - move a whole row into the next worksheet if the text in a particular cell of the first worksheet is Y (or Yes)

I am trying to set up a formula where worksheet 1 is a list of dates, names and the final column (I) is a simple Y or N (for Yes or No).
If the answer is Y (or Yes) then I would like the entire row to be copied into the next worksheet (worksheet 2) and if the answer is N (or No) then it does not go onto the next worksheet.
Is this possible to do, and if so how can i do it by cell formula (I don't want to change the srcipt module if possible)?
Any guidance would be gratfeully recieved.
Moving is a 2-step process in Excel (i.e. cut - paste) so this can't be done with a formula.
You could look into
autofilter to display all Y-records within the base data worksheet ... you then can copy/paste them manually
advanced filters to display and even copy Y-records, but within the same worksheet
writing a VBA procedure (not a function) to do the extraction job for you, where you first would set the Y/N field in each record manually, then press a button which moves the records; you gould go as far as capturing the event of entering Y into column 3 to automatically fire the move procedure, but I wouldn't recommend it ... what if the user accidentally entered Y ...
finally you could insert on the extraction sheet an array formula to display the Y-records; example:
Sheet 1
A B C
1 Index Info Flag
2 1 A Y
3 2 B N
4 3 C N
5 4 D Y
Sheet 2
copy headers of sheet 1 into A1..A3
select B1..B3 and enter formula =IF(Sheet1!C2="Y",Sheet1!A2:C2)
press Ctrl+Shift+ENTER to save as array formula
copy B1..B3 down
not very nice though, because you will get a FALSE FALSE FALSE for every N-record
Personally I would prefer 3) ... the button solution
You can do a workaround.
Create another tab or table within the original worksheet that pulls all your rows over via a conditional. This can be done with a VLOOKUP nested within an IF statement. (IF the cell = YES, VLOOKUP the rest of the row). I apologize for not including the exact formula, but its pretty easy to find videos etc on that portion.
On your other worksheet, use PowerQuery to query the original worksheet, and append the rows from your new table.
simply put = sign where u wanna see the result than go to that entire row and drag cursor to downward press enter. that's it.
regard: that's T.J
i entry some data i.e Customer name in Sheet1;s A1 cell , and I use this name in sheet2's cell B1 using this formula =Sheet1!B1 , now I want to move(transfer as CUT ) data from sheet2;B1 to sheet3's "C1" cel , from which formula it can be possible , ples tell
It's not the prettiest solution but it does work and I use it at my job on a workbook for logging checks received. It carries over the row if the check is postdated so that the row appears at the top of the next sheet. And it's an array formula so all the data is contiguous.
Let's use MikeD's data example above and expand upon it:
A B C D E
1 Index Info Flag Index 2 Info 2
2 1 A Y =If(C2="Y",A2,"") =If(C2="Y",B2,"")
3 2 B N =If(C3="Y",A3,"") =If(C3="Y",B3,"")
4 3 C N =If(C4="Y",A4,"") =If(C4="Y",B4,"")
5 4 D Y =If(C5="Y",A5,"") =If(C5="Y",B5,"")
Basically you are adding columns to the right of your data which checks to see if Column C equals "Y" and copies the row one cell at a time. So what we end up with is:
A B C D E
1 Index Info Flag Index 2 Info 2
2 1 A Y 1 A
3 2 B N
4 3 C N
5 4 D Y 4 D
Then on Sheet2 in cell A1 enter the following Array Formula (don't forget to use Ctrl+Shift+Enter):
=IFERROR(INDEX(Sheet1!$D$1:$D$5,SMALL(IF(Sheet1!$D$1:$D$5<>"",ROW(Sheet1!$D$1:$D$5)),ROW(1:1))),"")
Then in cell B1 you would enter a similar Array Formula:
=IFERROR(INDEX(Sheet1!$E$1:$E$5,SMALL(IF(Sheet1!$E$1:$E$5<>"",ROW(Sheet1!$E$1:$E$5)),ROW(1:1))),"")
Then you can highlight A1:B1 and drag the formulas down to A1:B5 and you should see this:
Index 2 Info 2
1 A
4 D
Then you can go back to Sheet1 and hide those nasty looking formula columns :).

Index/Match multiple columns in Excel

I have 2 sheets. Sheet 1 is set up similarly to:
Keyword Domain Rank
A Z 1
B Z 2
C Z 3
D Y 10
E Y 15
B Y 20
And sheet 2 is set up like:
Keyword (Domain Z) (Domain Y)
A 1 -
B 2 20
C 3 -
D - 10
I'm trying to have a formula that will compare the keywords in Sheet 2 with those in Sheet 1 and then return the rank that corresponds to the correct domain (that's specified in Sheet 2 for that column). I can't get any formula I use to evaluate. I've used 2 formulas so far:
=INDEX(Raw!$H$11:$H$322, MATCH(A3,IF(Raw!$D$11:$D$322=All!$B$2,Raw!$B$11:$B$322),0))
The above formula works, to a point. The problem is that it simple pulls the domain for the first instance of the keyword found, which doesn't always match the domain in the column of sheet 2. The second formula I've tried:
=INDEX(Raw!$H$11:$H$322, MATCH(B3,MATCH($C$2,Raw!$D$11:$D$322,0)))
To make the values appear in the Sheet 2 table, use the following formula:
=SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$F$1),$C$2:$C$7)
This returns 0 for non-matches - you can either format the cells to display 0 how you want, or you can use the longer/uglier:
=IF(SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7)<>0,SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7),"-")
To calculate the rank on the first sheet based on the data from the second sheet:
=VLOOKUP(A2,$F$2:$H$5,MATCH(B2,$G$1:$H$1,0)+1,FALSE)
For sample purposes, this just put your sheet2 data in F1:H5.
This looks for the corresponding keyword and then uses match to pick the right column. I named the columns Z and Y, but if you need Domain included that can be done as well. Note that this causes an error since there is no E defined in your second table - is that the case? If so, it can be adjusted to account for no matches as follows (assuming Excel 2007):
=IFERROR(VLOOKUP(A6,$F$2:$H$5,MATCH(B6,$G$1:$H$1,0)+1,FALSE),"Rank Not Found")
You could also use PivotTable with Keywords in rows and Domain names in columns. It seems like that would do the job and be a more robust solution.

Find values from one excel sheet in another

I have a column with the values in A excel sheet 1 1 1 2 2 2 3 3 3 4 4 4.... and i have in B excel sheet another column with values 1 2 4 ...., what i want is read values from B and see if they are in A sheet, for example if value 2 is in B sheet, then write true in a new column in sheet A in front of 2, and similarly false or nothing in front of value 3.
thanks
You can use a simple VLOOKUP - For example, assuming that the content of cell A1 of sheet B is 2, and that the sheet you call A is called SheetA, you can put the following formula in cell B1:
=IF(ISERROR(VLOOKUP(A1,SheetA!A:A,1,FALSE)),"",VLOOKUP(A1,SheetA!A:A,1,FALSE))
Use the approach described here:
http://spreadsheetpage.com/index.php/tip/comparing_two_lists_with_conditional_formatting/
Key formula is this: =COUNTIF(OldList,D2)=0, which you can use within the conditional formatting context as described, or to generate your true/false indicators as you mention in your question, i.e.:
=IF(COUNTIF(OldList,D2)=0,FALSE,TRUE)
OldList is just a range, and you don't need to use a named range. But if you don't name the range, just be sure to use absolute references for the range you're searching against.
Do you want a cool formula you can use to count the number of each matching value. Try this for your original post:
=IF(SUMPRODUCT(--($A1 =Sheet1!$A:$A) > 0), "True", "False")
And this to count the values: =SUMPRODUCT(--($A1 =Sheet1!$A:$A))

Excel macro to modify cells when enter is pressed

I'm looking for some help on a macro to reduce a cells value based on what was entered in another cell. I have 5 columns that I will be entering values into along with 2 columns that already have data. When I enter a number into one of the 5 columns, I want a window to pup up that says "Blah Blah", if I click yes, I would like the value in that cell to be subtracted from another cell that will need to be looked up with information from those other two columns.
Sheet 1:
A B C D E F G
1 5 10
Sheet 2:
A B C D E F G
1 2 4 6 8 10 12
2 2
3 4
4 5
So if I were to type '250' into A1 on sheet 1, the macro would reduce the value in cell F4 in sheet 2 by 250 because that's the value for the 5, 10 from sheet 1. Is something like this possible? There would be more filtering based on which column I type the values into, I should be able to modify that in later.
First, make sure that you can't accomplish a good enough solution with formulas, because writing a macro will be more work.
If you still need a macro, you will want to write a function around the Worksheet_Change event for the worksheet in question. This link will show you how to do this.
Be careful not to generate another Worksheet_Change while handling Worksheet_Change event. Since part of your response to the worksheet change is going to be another change, precede your code with Application.EnableEvents = False and follow it with Application.EnableEvents = True.
For the code itself to do the change, you'd just use the CELLS or OFFSET method (on the Range object). This would be done in the context of the Worksheet_Change event as Steven posted.

Resources