VBA Code:
Sub FindBeginEnd()
Dim m As Long
Dim Lastrow As Long
Dim ws As Worksheet
Set ws = Workbooks("TYPE A").Worksheets("Aimei Cheah Output")
Lastrow = Sheets(1).Cells(Rows.count, "A").End(xlUp).Row
Range("AT4").Value = "Shortage Begin"
Range("AU4").Value = "Shortage End"
For m = 5 To Lastrow
Cells(m, 46).Value = WorksheetFunction.Index(ws.Range("J3:V3"), WorksheetFunction.Match(True, ws.Range("J" & m & ":" & "V" & m) < 0, 0))
Cells(m, 47).Value = WorksheetFunction.Lookup(2, 1 / (ws.Range("J" & m & ":" & "V" & m)), ws.Range("J" & m & ":" & "V" & m))
Next m
End Sub
I tried many method to do this but can't work , anyone can help?