Really new to the Excel VBA. Been working on one task and tried to piece all different elements into one working macro.
Here is my goal
as you can see on the picture, there is a list of ID and names who reported their leave during the month.
I would like to translate into below format start date/ end date /hours taken
1 Tried the code to capture start date, but failed to resume the loop to capture the end date.
Sub FindMatchingValue()
Dim i As Integer, intValueToFind As Integer
intValueToFind = 8
For i = 1 To 500 ' Revise the 500 to include all of your values
If Cells(2, i).Value = intValueToFind Then
MsgBox ("Found value on row " & i)
Cells(2, 35).Value = Cells(1, i) 'copy the start date to same row column 35
Exit Sub
End If
Next i
' This MsgBox will only show if the loop completes with no success
MsgBox ("Value not found in the range!")
End Sub
2 End date would be the last day for employee who took leave in consecutive days.
Really appreciate help from our community.