I have this script that searches for a defined string and deletes the column if it finds it. I want to run this same search across all sheets in the workbook. So far I have tried setting it up like this. But it will only run on the Active Sheet.
Sub RunMacroOnAllSheetsToRight()
For i = ActiveSheet.Index To Sheets.Count
    Call MyFunction(i)
Next i
End Sub
Function MyFunction(i)
Dim c As Range
            Dim str As String
            str = "SearchStringHere"
            For Each c In ActiveSheet.UsedRange
               If InStr(c.Value, str) > 0 Then
               c.EntireColumn.Delete Shift:=xlToLeft
               End If
            Next c
End Function
Script now cycles through but only deletes single columns for some reason. Needs to be able to match and delete multiple columns per sheet.
 
     
    