counting 7th data after zero

jheiz

New Member
Joined
Jun 11, 2021
Messages
5
Office Version
  1. 2013
hello good day, i was working on monitoring the 7th day duty of guards, i don't know what formula to be used.

i have a thousands of data to check it one by one. i just want to have a formula that marks or emphasized the 7th day data after zero. thank you.

attached is a sample.

1623396964610.png
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi jheiz and welcome to MrExcel.

It is not a formula that I like, but maybe someone else can provide us with a more compact formula.

Dante Amor.xlsm
ABCDEFGHIJKLMNOPQR
1
2EmpName1234567891011121314157th Day
388081212121212088888 
4128888012121212128088 
51288888812121212128087
60888888001212121280 
712081212121212012121212128 
8128881201212121208888 
9121212120121212888888812
Hoja2
Cell Formulas
RangeFormula
R3:R9R3=IF(COUNTIF(C3:I3,">0")=7,I$2,IF(COUNTIF(D3:J3,">0")=7,J$2,IF(COUNTIF(E3:K3,">0")=7,K$2, IF(COUNTIF(F3:L3,">0")=7,L$2,IF(COUNTIF(G3:M3,">0")=7,M$2,IF(COUNTIF(H3:N3,">0")=7,N$2, IF(COUNTIF(I3:O3,">0")=7,O$2,IF(COUNTIF(J3:P3,">0")=7,P$2,IF(COUNTIF(K3:Q3,">0")=7,K$2,"")))))))))
 
Upvote 0
thank you sir. ill try this formula., i just wonder if there are 2, 7th day duty per row.
 
Upvote 0
hello sir dante thanks for your help, i just use the formula that you provide. and it is working on a single output. but on the 2nd day it is not applicable.



1623496932605.png
 
Upvote 0
@DanteAmor , yes, I also struggled with this which initially seemed simple. I did see a typo where the last cell in your formula is K$2 but should be Q$2.

@jheiz I took a slightly different format and added to Dante's work. I use a start date in C2 and then formatting to show the month in C1 and just the day of the month in C2 to Q2. The result in R3 to R16 is the date but just formatted as dd-mmm

You can only have two occurrences if the first is on the 7th or 8th so I've added column S where I do the check for a second set of non-zero values (again, building on Dante's work).

P.S. If you can use XL2BB or even just paste your data as text and not an image then we won't need to retype the data.

JHeiz3.xlsx
ABCDEFGHIJKLMNOPQRS
1June
2EmpName1234567891011121314157th Day2nd 7th
388081212121212088888  
4128888012121212128088  
51288888812121212128087-Jun 
60888888001212121280  
71208121212121212121212121289-Jun 
8128081212121212120888810-Jun 
9121212121212012888888814-Jun 
1012121212121212088888887-Jun 
11121212121212121208888887-Jun 
1201212121212121288888888-Jun15-Jun
1312121212121212088888887-Jun 
1412121212121212188888887-Jun14-Jun
150121212121212888888888-Jun15-Jun
16821212121200888888815-Jun 
Sheet1
Cell Formulas
RangeFormula
C1C1=C2
D2:Q2D2=C2+1
R3:R16R3=IF(COUNTIF(C3:I3,">0")=7,I$2,IF(COUNTIF(D3:J3,">0")=7,J$2,IF(COUNTIF(E3:K3,">0")=7,K$2, IF(COUNTIF(F3:L3,">0")=7,L$2,IF(COUNTIF(G3:M3,">0")=7,M$2,IF(COUNTIF(H3:N3,">0")=7,N$2, IF(COUNTIF(I3:O3,">0")=7,O$2,IF(COUNTIF(J3:P3,">0")=7,P$2,IF(COUNTIF(K3:Q3,">0")=7,Q$2,"")))))))))
S3:S16S3=IF(R3=$I$2,IF(COUNTIF(J3:P3,">0")=7,P$2,""),IF(R3=$J$2,IF(COUNTIF(K3:Q3,">0")=7,Q$2,""),""))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I3:Q18Expression=OR($R3=I$2,$S3=I$2)textNO
 
Upvote 0
@Toadstool thanks for your help. sorry for the data that i upload. im just new to this site so i am not familiar with XL2BB. I'll try to use the formula that you provided. i really helps me a lot if it works properly since i am dealing with thousands of data.
 
Upvote 0
Try the following macros.
If you want them in a column:

Dante Amor
ABCDEFGHIJKLMNOPQR
1
2EmpName1234567891011121314157th Day
388081212121212088888
4121212121212121212121212121287, 14
51288888812121212128087
60888888001212121280
712081212121212012121212128
8128881201212121208888
9121212120121212888888812
1012121212121212012121212121287, 15
111208121212120121212121212815
Hoja3


VBA Code:
Sub Conting7()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, n As Long
  
  Range("R3:R" & Rows.Count).ClearContents
  a = Range("C2", Range("Q" & Rows.Count).End(3)).Value
  ReDim b(2 To UBound(a), 1 To 1)
  For i = 2 To UBound(a, 1)
    n = 0
    For j = 1 To UBound(a, 2)
      If a(i, j) <> 0 Then
        n = n + 1
        If n = 7 Then
          n = 0
          If b(i, 1) = "" Then b(i, 1) = a(1, j) Else b(i, 1) = b(i, 1) & ", " & a(1, j)
        End If
      Else
        n = 0
      End If
    Next j
  Next i
  
  Range("R3").Resize(UBound(a) - 1).Value = b
End Sub

____
If you want them in two columns:

varios 13jun2021.xlsm
ABCDEFGHIJKLMNOPQRS
1
2EmpName1234567891011121314157th Day7th Day
388081212121212088888
412121212121212121212121212128714
51288888812121212128087
60888888001212121280
712081212121212012121212128
8128881201212121208888
9121212120121212888888812
101212121212121201212121212128715
111208121212120121212121212815
Hoja3


VBA Code:
Sub Conting7_v2()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, n As Long
  
  Range("R3:S" & Rows.Count).ClearContents
  a = Range("C2", Range("Q" & Rows.Count).End(3)).Value
  ReDim b(2 To UBound(a), 1 To 2)
  For i = 2 To UBound(a, 1)
    n = 0
    For j = 1 To UBound(a, 2)
      If a(i, j) <> 0 Then
        n = n + 1
        If n = 7 Then
          n = 0
          If b(i, 1) = "" Then b(i, 1) = a(1, j) Else b(i, 2) = a(1, j)
        End If
      Else
        n = 0
      End If
    Next j
  Next i
  
  Range("R3").Resize(UBound(a) - 1, 2).Value = b
End Sub

___
HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Conting7 or Conting7_v2) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,537
Messages
6,125,394
Members
449,222
Latest member
taner zz

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