Hi All.
I create procedure with loop and try to call another procudure when match found.
Sub ProcessSheets(btnName As String, assignSheetName As String)
    Dim wsExec As Worksheet
    Dim sheetNames As Variant
    Dim loopSheetName As Variant
    
    ' List of sheet names
    sheetNames = Array("W1", "W2", "W3", "W4", "W5")
    
    ' Find and set the execution sheet based on the button name
    For Each loopSheetName In sheetNames
        On Error Resume Next
        Set wsExec = ThisWorkbook.Sheets(loopSheetName)
        On Error GoTo 0
        
        If Not wsExec Is Nothing Then
            ' Call ProcessButton with the appropriate parameters
            ProcessButton wsExec, btnName, assignSheetName
        End If
    Next loopSheetName
End Sub
After line -
ProcessButton wsExec, btnName, assignSheetName execution
jump to ProcessButton() procedure
When I commented "IF" statement in the loop I'm getting iteration.
What is wrong? How to fix problem?

Thanks