Multiple Fault Code Mapping Based on Time Slot Ranges

Surendra Bhilare

New Member
Joined
Mar 29, 2025
Messages
13
Office Version
  1. 2013
Platform
  1. Windows
Dear Team,

We have two sheets, Sheet1 and Sheet3.

Our requirement is to extract multiple fault codes from Sheet3 and display them in Sheet1, based on the following parameters:
  • Posting Date
  • Work Center
  • Time Slot
Key Requirement:
  • If the time slot in Sheet3 is mentioned as 07-15, the corresponding fault codes should be distributed across the time slots 07:00-08:00 to 14:00-15:00 in Sheet1.
  • The fault codes should be correctly placed within the respective time slot ranges.
  • Multiple codes added with "," separator.
  • We are using excel version 2013.
  • Please take for midnight range slot.
Please let us know the best way to achieve this.

Sheet 1 - Data require in sheet 1.


Posting DateWork CenterDepartmentBay07-0808-0909-1010-1111-1212-1313-1414-1515-1616-1717-1818-1919-2020-2121-2222-2323-0000-0101-0202-0303-0404-0505-0606-07
01-03-2025SCMSCS02SOD Cutting0


Sheet 3 - Data to be pick from Sheet 3


Start TimeEnd TimeTime SlotWork centerFault Code DescrDown time date.
07:00:0007:30:0007-08SCMSCS02MECH BREAK DOWN01-03-2025
07:30:0008:00:0007-08SCMSCS02NO MANPOWER01-03-2025
08:00:0008:30:0008-09SCMSCS02NO PLANNING01-03-2025
08:30:0009:00:0008-09SCMSCS02DIE SETUP01-03-2025
09:00:0010:00:0009-10SCMSCS02HEAT ISSUE01-03-2025
10:00:0011:00:0010-11SCMSCS02MECH BREAK DOWN01-03-2025
11:00:0012:00:0011-12SCMSCS02LINE CHANGE01-03-2025
12:00:0013:00:0012-13SCMSCS02TEA BREAK01-03-2025
18:00:0019:00:0018-19SCMSCS02RING PANA CHANGE01-03-2025
19:00:0019:30:0019-20SCMSCS02NO MANPOWER01-03-2025
20:00:0020:30:0020-21SCMSCS02TEA BREAK01-03-2025
23:00:0007:00:0023-07SCMSCS02ELECTRICAL BREAKDOWN01-03-2025
1743226232590.png
1743226275809.png



Thanks & Regards,
Surendra Bhilare
 
Something like this,
Book1
ABCDEF
1Start TimeEnd TimeTime SlotWork centerFault Code DescrDown time date
27:00:007:30:0007-08SCMSCS02MECH BREAK DOWN01/03/25
37:30:008:00:0007-08SCMSCS02NO MANPOWER01/03/25
48:00:008:30:0008-09SCMSCS02NO PLANNING01/03/25
58:30:009:00:0008-09SCMSCS02DIE SETUP01/03/25
69:00:0010:00:0009-10SCMSCS02HEAT ISSUE01/03/25
710:00:0011:00:0010-11SCMSCS02MECH BREAK DOWN01/03/25
811:00:0012:00:0011-12SCMSCS02LINE CHANGE01/03/25
912:00:0013:00:0012-13SCMSCS02TEA BREAK01/03/25
1018:00:0019:00:0018-19SCMSCS02RING PANA CHANGE01/03/25
1119:00:0019:30:0019-20SCMSCS02NO MANPOWER01/03/25
1220:00:0020:30:0020-21SCMSCS02TEA BREAK01/03/25
1323:00:007:00:0023-07SCMSCS02ELECTRICAL BREAKDOWN01/03/25
147:00:007:30:0007-15SCMSCS02MECH BREAK DOWN02/03/25
157:30:008:00:0007-08SCMSCS02NO MANPOWER02/03/25
168:00:008:30:0008-09SCMSCS02NO PLANNING02/03/25
178:30:009:00:0008-09SCMSCS02DIE SETUP02/03/25
189:00:0010:00:0009-10SCMSCS02HEAT ISSUE02/03/25
1910:00:0011:00:0010-11SCMSCS02MECH BREAK DOWN02/03/25
2011:00:0012:00:0011-12SCMSCS02LINE CHANGE02/03/25
2112:00:0013:00:0012-13SCMSCS02TEA BREAK02/03/25
2218:00:0019:00:0018-19SCMSCS02RING PANA CHANGE02/03/25
2319:00:0019:30:0019-20SCMSCS02NO MANPOWER02/03/25
2420:00:0020:30:0020-21SCMSCS02TEA BREAK02/03/25
2523:00:007:00:0023-07SCMSCS02ELECTRICAL BREAKDOWN02/03/25
Sheet3

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1Posting DateWork CenterDepartmentBay07-0808-0909-1010-1111-1212-1313-1414-1515-1616-1717-1818-1919-2020-2121-2222-2323-0000-0101-0202-0303-0404-0505-0606-07
201/03/25SCMSCS02SOD Cutting0MECH BREAK DOWN NO MANPOWERNO PLANNING DIE SETUPHEAT ISSUEMECH BREAK DOWNLINE CHANGETEA BREAKRING PANA CHANGENO MANPOWERTEA BREAKELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWN
302/03/25SCMSCS02SOD Cutting0MECH BREAK DOWN NO MANPOWERMECH BREAK DOWN NO PLANNING DIE SETUPMECH BREAK DOWN HEAT ISSUEMECH BREAK DOWNMECH BREAK DOWN LINE CHANGEMECH BREAK DOWN TEA BREAKMECH BREAK DOWNMECH BREAK DOWNRING PANA CHANGENO MANPOWERTEA BREAKELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWN
Sheet1

VBA Code:
Sub testMapping()
    Dim a%, b%, c%, d%, e%, f%, g$, h$, i$, j$, k$, l$, m As Worksheet, n As Worksheet
    Dim o&, p&, q&, r&, s$, t As Range, u As Range, v As String

    Set m = Worksheets("Sheet3")
    Set n = Worksheets("Sheet1")

    a = m.Cells(m.Rows.Count, 1).End(xlUp).Row
    b = n.Cells(n.Rows.Count, 1).End(xlUp).Row
    Set t = n.Rows(1)

    For c = 2 To a
        g = Format(m.Cells(c, 6).Value, "d/m/yyyy")
        h = Trim(m.Cells(c, 4).Value)
        i = Trim(m.Cells(c, 3).Value)
        j = Trim(m.Cells(c, 5).Value)

        f = 0
        For d = 2 To b
            If Format(n.Cells(d, 1).Value, "d/m/yyyy") = g And Trim(n.Cells(d, 2).Value) = h Then
                f = d
                Exit For
            End If
        Next d
        If f = 0 Then GoTo y

        If InStr(i, "-") > 0 Then
            o = Val(Split(i, "-")(0))
            p = Val(Split(i, "-")(1))
            q = o
            Do
                r = (q + 1) Mod 24
                s = Format(q, "00") & "-" & Format(r, "00")
                Set u = t.Find(What:=s, LookIn:=xlValues, LookAt:=xlWhole)
                If Not u Is Nothing Then
                    With n.Cells(f, u.Column)
                        If .Value = "" Then
                            .Value = j
                        ElseIf InStr(1, .Value, j, vbTextCompare) = 0 Then
                            .Value = .Value & Chr(10) & j
                        End If
                        .WrapText = True
                    End With
                End If
                q = (q + 1) Mod 24
            Loop While q <> p
        End If
y:
    Next c
    
End Sub
 
Upvote 0
Dear Sam,

Also please confirm if we use the VBA code then where we copy this code in under objects as per attached screenshot.

As per provided VBA code the column names are different then how can we assign the correct coloumn number in vba code.

Please check and share the revise code with all correct coloumn names which are showing in screenshots which we have provided earlier..

1743400926100.png
 
Upvote 0
Book1
ABCDEFG
1Start TimeEnd TimeTime SlotWork centerFault Code DescrDown time date
207:00:0007:30:007-8SCMSCS02MECH BREAK DOWN03-01-2025
307:30:0008:00:008-9SCMSCS02NO MANPOWER03-01-2025
408:00:0008:30:009-10SCMSCS02NO PLANNING03-01-2025
508:30:0009:00:0010-11SCMSCS02DIE SETUP03-01-2025
609:00:0010:00:0011-12SCMSCS02HEAT ISSUE03-01-2025
710:00:0011:00:0012-13SCMSCS02MECH BREAK DOWN03-01-2025
811:00:0012:00:0013-14SCMSCS02LINE CHANGE03-01-2025
912:00:0013:00:0014-15SCMSCS02TEA BREAK03-01-2025
1018:00:0019:00:0015-16SCMSCS02RING PANA CHANGE03-01-2025
1119:00:0019:30:0016-17SCMSCS02NO MANPOWER03-01-2025
1220:00:0020:30:0017-18SCMSCS02TEA BREAK03-01-2025
1323:00:0007:00:0018-19SCMSCS02ELECTRICAL BREAKDOWN03-01-2025
1423:00:0007:00:0019-20SCMSCS02MECH BREAK DOWN03-02-2025
1523:00:0007:00:0020-21SCMSCS02NO MANPOWER03-02-2025
1623:00:0007:00:0021-22SCMSCS02NO PLANNING03-02-2025
1723:00:0007:00:0022-23SCMSCS02DIE SETUP03-02-2025
1823:00:0007:00:0023-24SCMSCS02HEAT ISSUE03-02-2025
1923:00:0007:00:000-1SCMSCS02MECH BREAK DOWN03-02-2025
2023:00:0007:00:001-2SCMSCS02LINE CHANGE03-02-2025
2123:00:0007:00:002-3SCMSCS02TEA BREAK03-02-2025
2223:00:0007:00:003-4SCMSCS02RING PANA CHANGE03-02-2025
2323:00:0007:00:004-5SCMSCS02NO MANPOWER03-02-2025
2423:00:0007:00:005-6SCMSCS02TEA BREAK03-02-2025
2523:00:0007:00:006-7SCMSCS02ELECTRICAL BREAKDOWN03-02-2025
Sheet3


Cell Formulas
RangeFormula
E2:AB3E2=CONCAT(IF((Sheet3!$F$2:$F$25=$A2)*(Sheet3!$D$2:$D$25=$B2)*(Sheet3!$C$2:$C$25=E$1),Sheet3!$E$2:$E$25,""))
Press CTRL+SHIFT+ENTER to enter array formulas.

ARRAY formula in E2 copied up to AB3
Excel Formula:
=CONCAT(IF((Sheet3!$F$2:$F$25=$A2)*(Sheet3!$D$2:$D$25=$B2)*(Sheet3!$C$2:$C$25=E$1),Sheet3!$E$2:$E$25,""))
 
Upvote 0
Dear Team,

I am using the formula that was shared, but I am encountering a "#NAME?" error in the result. Could you please check the formula and confirm if there are any issues?

Additionally, the current formula fetches only a single fault code per time slot. However, we require multiple fault codes where available in the given time slot. Please suggest a solution to accommodate this requirement.

Looking forward to your support.
 
Upvote 0
Require result output as below.

eWork CenterDepartmentBay07-0808-0909-1010-1111-1212-1313-1414-1515-1616-1717-1818-1919-2020-2121-2222-2323-0000-0101-0202-0303-0404-0505-0606-07
201/03/25SCMSCS02SOD Cutting0MECH BREAK DOWN NO MANPOWERNO PLANNING DIE SETUPHEAT ISSUEMECH BREAK DOWNLINE CHANGETEA BREAKRING PANA CHANGENO MANPOWERTEA BREAKELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWN
302/03/25SCMSCS02SOD Cutting0MECH BREAK DOWN NO MANPOWERMECH BREAK DOWN NO PLANNING DIE SETUPMECH BREAK DOWN HEAT ISSUEMECH BREAK DOWNMECH BREAK DOWN LINE CHANGEMECH BREAK DOWN TEA BREAKMECH BREAK DOWNMECH BREAK DOWNRING PANA CHANGENO MANPOWERTEA BREAKELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWNELECTRICAL BREAKDOWN
 
Upvote 0
CONCAT function is not available in 2013.
Pl use this ARRAY formula in E2 copied to full range.
Excel Formula:
=IFERROR(INDEX(Sheet3!$E$2:$E$25,SMALL(IF((Sheet3!$F$2:$F$25=$A2)*(Sheet3!$D$2:$D$25=$B2)*(Sheet3!$C$2:$C$25=E$1),ROW(Sheet3!$E$2:$E$25),""),1)-ROW($E$1)),"")
 
Upvote 0
Dear Team,


I have used the provided formula, but it only displays fault codes for the 07:00-08:00 time slot. For all other time slots, the result is blank.


Additionally, we need the formula to fetch multiple fault codes available in a given time slot. There may also be cases where the time slot is different, such as 07:00-15:00. Please provide a solution that accommodates these requirements.


Looking forward to your support.
 
Upvote 0

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