Need help with Excel function

Avi11

New Member
Joined
Apr 6, 2018
Messages
4
First post here and a basic user of excel. Go easy on me.

I have a list of parts that were only available on certain dates (marked by 1 as available and 0 as not available in Sheet2). I have a separate table where I want to find out by part if they were available at least Y times in a X number of days.

Here is what I tried and getting #Value !:
=IF(COUNTIFS(Sheet2!$A$4:$A$8,"="&$A4,Sheet2!$B$3:$J$3,">="&B$3,Sheet2!$B$3:$J$3,"<="&B3+($D$1-1))>=$G$1,1,0)

where A is column for parts on both sheets
B3-J3 has dates on both sheets
D1 has the number of days (X)
G1 has the availability (Y)

Any help is appreciated.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
COUNTIFS() requires that all ranges have the same number of rows and columns. A4:A8 is five rows by one column; B3:J3 is one row by nine columns. Would you please post a sample of your data—it's hard for me to reconstruct your worksheets just from the description.
 
Upvote 0
Here are the 2 sheets I described:


Book1
ABCDEFGHIJ
1X4Y2
2
31/15/20181/16/20181/17/20181/18/20181/19/20181/20/20181/21/20181/22/20181/23/2018
4ABC1245X#VALUE!
5SDHG3K3
6SJKFH23
7KJASFH22L
8LSDNF232
Sheet1
Cell Formulas
RangeFormula
B4=IF(COUNTIFS(Sheet2!$A$4:$A$8,"="&$A4,Sheet2!$B$3:$J$3,">="&B$3,Sheet2!$B$3:$J$3,"<="&B3+($D$1-1))>=$G$1,1,0)




Book1
ABCDEFGHIJ
31/15/20181/16/20181/17/20181/18/20181/19/20181/20/20181/21/20181/22/20181/23/2018
4ABC1245X010000101
5SDHG3K3010000010
6SJKFH23000001000
7KJASFH22L100010000
8LSDNF232100100001
Sheet2
 
Upvote 0
First post here and a basic user of excel. Go easy on me.

I have a list of parts that were only available on certain dates (marked by 1 as available and 0 as not available in Sheet2). I have a separate table where I want to find out by part if they were available at least Y times in a X number of days.

Here is what I tried and getting #Value !:
=IF(COUNTIFS(Sheet2!$A$4:$A$8,"="&$A4,Sheet2!$B$3:$J$3,">="&B$3,Sheet2!$B$3:$J$3,"<="&B3+($D$1-1))>=$G$1,1,0)

where A is column for parts on both sheets
B3-J3 has dates on both sheets
D1 has the number of days (X)
G1 has the availability (Y)

Any help is appreciated.

So I understand you want to know if the part was available at least 2 times, but I don't understand the number of days part. Do you mean was it available 2 times in a 4 day period?
 
Upvote 0
So I understand you want to know if the part was available at least 2 times, but I don't understand the number of days part. Do you mean was it available 2 times in a 4 day period?

Yes I would like to know if the part was available at least 2 times in a 4 day period.
 
Upvote 0
I'm sure this could be done with a formula, but it's eluding me at the moment. A UDF is straightforward, though:

A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
L​
1​
nTimes
2​
2​
3​
nDays
4​
4​
5​
Item \ Day
1​
2​
3​
4​
5​
6​
7​
8​
9​
6​
ABC1245X
1​
0​
1​
0​
1​
0​
0​
1​
1​
3​
K6: =MinN(nTimes, nDays, B6:J6)
7​
SDHG3K3
1​
1​
1​
1​
0​
0​
0​
1​
0​
3​
8​
SJKFH23
0​
0​
0​
1​
1​
0​
1​
1​
0​
2​
9​
KJASFH22L
0​
0​
0​
0​
1​
0​
0​
1​
0​
0​
10​
LSDNF232
1​
0​
1​
0​
0​
1​
1​
1​
0​
2​

Code:
Function MinN(M As Long, N As Long, r As Range) As Long
  Dim avdInp        As Variant
  Dim nInp          As Long
  Dim i             As Long
  Dim k             As Long

  avdInp = r.Value
  nInp = UBound(avdInp, 2)

  For i = 1 To N
    k = k + avdInp(1, i)
  Next i
  If k >= M Then MinN = MinN + 1

  For i = i To nInp - N + 1
    k = k - avdInp(1, i - N) + avdInp(1, i)
    If k >= M Then MinN = MinN + 1
  Next i
End Function
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top