Alright, so I have an idea, but I am not sure if there is a way to accomplish this. Starting with this equation:
=IF(OR(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"I","A","X","R","K","E","AL","FFSL","ADM*"})))=10),"80 Hours","Error")
I would like to embed an AND statement within the same IF statement, if that is at all possible. For instance, the equation above checks all the possible 8 hours shifts. If there are 10 of them then the employee is schedule to work 80 hours. I next need to check for a combination of 4 ten hour shifts and 5 eight hour shifts. I then need to continue checking other possible combinations that would get the employee to 80 hours.
I know this equation below does not work, but this is what I am trying to do something similar to.
=IF(OR(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"I","A","X","R","K","E","AL","FFSL","ADM*"})))=10,(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"R-10","I-10","X-10","A-10"})))=4,AND(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"I","A","X","R","K","E","AL","FFSL","ADM*"})))=5),"80 Hours","Error")
Essentially I am trying to embed an AND statement within the original OR statement. Not sure if that is even allowed. I am saying something like this:
IF 1 OR (2 AND 3) OR (3 AND 4), etc...
Shouldn't it be like this?
=IF(OR(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"I","A","X","R","K","E","AL","FFSL","ADM*"})))=10,
AND(ARRAYFORMULA(SUM(COUNTIF(B7:O7,{"R-10","I-10","X-10","A-10"})))=4, ARRAYFORMULA(SUM(COUNTIF(B7:O7,"I","A","X","R","K","E","AL","FFSL","ADM*"})))=5)) ,"80 Hours","Error")
In excel AND and OR are functions, not operators. So IF 1 OR (2 AND 3) OR (3 AND 4).. will translate to
IF( OR(1, AND(2, 3), AND(3,4)) , <true_statement>, <false_statement>)
Related
I'm not even sure how to ask this so please excuse the roundabout manner forthcoming.
I have a list of tasks and would like to use =INDEX to create my array. However, there are multiple different versions of the task that could show up, and I would like to have all possible avenues covered when creating (only 4 differences).
The name of the range is TaskCode. I want to have it so I can return the first seven numbers, the period, and then only the digits directly after the period. So in case 1, I would want 0527011.3, in case 2 I would want 0527011.01, in case 3 I would want 0527011.23, and in case 4 I'd want 0527011.3.
I initially did =LEFT(TaskCode,10) but that will obviously not work in case 1 or 4. Basically I need to say cut off EITHER at the second period OR the first blank.
Thanks
=LEFT(A2,FIND("|",SUBSTITUTE(A2&".",".","|",2))-1)
In a dataset I have answers that participants to a survey gave. The answers are in one example numbered 1 to 5, with 1 being yes, and 2 to 5 being variants of no.
20 or so similar questions have been asked, and participants can be in either one of 20 subgroups. Questions were categorized into 6 classes.
Now the best way to go about such a dataset would normally be the use of a pivot-table, however the way the data is set up doesn't work with a pivot table, and due to the sheer size of the dataset remodelling isn't efficient.
To extract the amount of people in a certain subgroup that answered yes for questions in a certain class I use the following function:
=SuMPRODUCT(--(Test!D$4:$CC$1824=1)*(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))
In which Test!D$4:$CC$1824 is the range where answers are given, and the other two are ranges for subgroup and classes respectively.
By using --(Test!D$4:$CC$1824=1) I convert all data to 0's except for where participants answered yes (cell value = 1).
Now I would like to do the same thing for where they answered no, so the value is either 2 or 3 or 4 or 5. The ideal way would be to append some OR logic into the first test, coming about something like this: --(Test!D$4:$CC$1824={2,3,4,5})
Ofcourse this doesn't work, but is there any simple notation besides retyping the first part 4 times, and adding them together?
I'd say you could just use >1 instead of =1
For selected results like 1 and 3 and 5 you probably need to add the sumproducts of each number.
Sidenote: the -- is not necessary anymore as it is just for converting true and false to 1 and 0 when there is only one bracket inside sumproduct
The OR operation can be mimicked by adding all of the possibilities together.
=SuMPRODUCT(((Test!D$4:$CC$1824=2)+(Test!D$4:$CC$1824=3)+(Test!D$4:$CC$1824=4)+(Test!D$4:$CC$1824=5))*
(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))
If there is any possibilitiy that two could be correct (in this case there isn't) wrap the sum in the SIGN function to get only zero or one.
=SuMPRODUCT(SIGN((Test!D$4:$CC$1824=2)+(Test!D$4:$CC$1824=3)+(Test!D$4:$CC$1824=4)+(Test!D$4:$CC$1824=5))*
(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))
I'm attempting to combine these 2 statements with an OR statement. The first is a number that has to be shortened by 3 digits to the left. And the second is an alphanumeric statement that is 6 digits long. I was thinking =--(OR(MID(B2,4,7),MID(B2,1,7))). Can anyone help?
=Concatenate(Right(text(B2,0),len(text(B2,0))-3),Left(text(B2,0),6))
I had to take a big guess at what you were trying to achieve based on your question.
I have a problem that seems so simple, but I can't wrap my head around it. I have a large database, and i have two separate columns that unfortunately need to stay that way, which together are defining the time of an incident: Column A consists of an integer number "1" to "12", and Column B consists of cells with either "PM" or "AM". I need a separate column that gives me a "1" for anything that happened between 8 AM and 4 PM and a "0" for all else. Part of the problem obviously are the "12" "PM" rows. That's all I have so far:
=IF(AND(A1>=8, A1<=11),IF(B1="AM",1,0),0)
, which puts out correctly a "1", if anything happened between 8 AM and 11 AM, but not the rest. I need to combine it with:
=IF(AND(A1>=1, A1<=4),IF(B1="PM",1,0),0)
and:
=IF(AND(A1=12),IF(B1="PM",1,0),0)
but I have no idea how to combine all of these in one statement at the same time. Can anybody help?
This was a fun exercise - I'm sure there's a dozen ways to do it but here's what I found:
=IF(AND(TIME(IF(B1="PM",A1+12,A1),0,0)>=TIME(8,0,0),TIME(IF(B1="PM",A1+12,A1),0,0)<=TIME(11,0,0)),1,0)
Goes in C1
So my approach was --
If B1 is PM, then give me A1 + 12 (hours), otherwise just give me A1
IF(B1="PM",A1+12,A1)
Return a time value equal to that many hours
TIME(IF(B1="PM",A1+12,A1),0,0)
Check and see if it's greater than a value of exactly 8 hours...
TIME(IF(B1="PM",A1+12,A1),0,0)>=TIME(8,0,0)
Then wrap it in an And statement with an identical function asking if it's less than 11.
I don't like that it repeats itself, and that I have to use TIME(8,0,0) to return a value of 8 hours.. Maybe you or someone else can offer improvements or other suggestions.
Or you can try this:
=IF(AND(TIMEVALUE(A1&" "&B1)>=(8/24),TIMEVALUE(A1&" "&B1)<=(16/24)),1,0)
Simple and direct. You just need to convert what you have to its equivalent time value(between 0-1 in Excel).
And then just evaluate it using AND operand with 8/24(8AM) and 16/24(4PM). HTH.
Result:
This question already has answers here:
Unique Random Numbers using VBA
(3 answers)
Closed 8 years ago.
I'm trying to make a set box of cells populate in a random appearing order. I have it just running through way more iterations than necessary so that the entire box populates. I wish to exclude previous selections to make the process quicker and more fluid. Thank you!
I am sure this has millins of anwers. what I will explain you what I would do. then you can paste your code and if you have problems someone can help you.
I would make a routine that sorts your array randomly, how? add to your array another column where you will place a ramdon number generated by excel. then sort your array according to your random number. I will make an example:
Original array:
(your int column,Rand column)
(1,0.3212)
(2,0.7423)
(3,0.0311)
(4,0.03144)
(5,0.952)
then if you order it you will get something like this:
5
2
1
4
3
then all you have to do is return next item in your array and of cource they wil never repeat.
I think this is a really fast way.
Hope it helps