I have a Sub that checks a workbook for duplicate worksheets and deletes them. The problem is that after removing the duplicate I want to restart the sub to make sure there are no more duplicates. I tried to use a command just to go to the Sub start but when the Sub completes it then goes back to where it jumped out of the Sub and gives an Out of Range Error. I also tried just setting my loop counters back to their start values but that didn't work either.
Can anyone help please? My code is -
Sub dupCheck()
Dim sht As Worksheet, i As Integer, j As Integer
'find duplicate sheets by checking Cell C5 using the For Loop
For i = 1 To Sheets.Count - 1
For j = (i + 1) To Sheets.Count
If Sheets(i).Range("C5") = Sheets(j).Range("C5") Then Sheets(j).Delete: dupCheck
Next
Next
End Sub
Can anyone help please? My code is -
Sub dupCheck()
Dim sht As Worksheet, i As Integer, j As Integer
'find duplicate sheets by checking Cell C5 using the For Loop
For i = 1 To Sheets.Count - 1
For j = (i + 1) To Sheets.Count
If Sheets(i).Range("C5") = Sheets(j).Range("C5") Then Sheets(j).Delete: dupCheck
Next
Next
End Sub