Dear All,
I haven't coded for VBA for ages, and having some issue with this algorithm; I want excel to look up for free available leaves days an employee is entitled on previous months, to be offset with a current day on the current month, all unused available days are marked with string "P" and red background.
This code stops the execution of the algorithm in the first sheet, it ignores the loop "For I = 1 To ThisWorkbook.Sheets.Count"
The main goal is to after successfully, find both string "P" in a cell with red background in the "ra.entirerow.select", calls the module Found, which is basically a msgbox asking to change the background of activecell string "P" red to grey background, and hence , changing the initial day which was marked red, not available anymore for future leaves, but somehow the loop closes on first sheet.
Thanks
I haven't coded for VBA for ages, and having some issue with this algorithm; I want excel to look up for free available leaves days an employee is entitled on previous months, to be offset with a current day on the current month, all unused available days are marked with string "P" and red background.
VBA Code:
Sub Start()
On Error Resume Next
Dim WS_Count As Integer
Dim ra As Range
Dim rb As Range
Dim I As Integer
Dim strText As String
strText = Range(Cells(Selection.Row, 2).Address).Value
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 1 To ThisWorkbook.Sheets.Count
ActiveWorkbook.Worksheets(I).Select
Set ra = Cells.Find(What:=strText, SearchFormat:=False)
If Not ra Is Nothing Then
ra.EntireRow.Select
Application.FindFormat.Interior.Color = 255
Set rb = Cells.Find(What:="P", SearchFormat:=True)
If Not rb Is Nothing Then
Call Found
Else
End If
End If
Next I
End Sub
This code stops the execution of the algorithm in the first sheet, it ignores the loop "For I = 1 To ThisWorkbook.Sheets.Count"
The main goal is to after successfully, find both string "P" in a cell with red background in the "ra.entirerow.select", calls the module Found, which is basically a msgbox asking to change the background of activecell string "P" red to grey background, and hence , changing the initial day which was marked red, not available anymore for future leaves, but somehow the loop closes on first sheet.
Thanks