Hello,

I am trying to figure out how to use error handling to skip and iteration. Here is my code:

Sub AddSheets(Host, Data1, Data2)
Set NewSht = Sheets.Add(after:=Sheets(Sheets.count), Type:=xlWorksheet)
'I know this is really bad practice for error handling and this is where I need help
On Error Resume Next
With NewSht
  .Name = Host
  .Range("A1").Value = Data1
  .Range("A2").Value = Data2
End With
End Sub
I am trying to prevent a new sheet being created with the same name as another sheet. Without the "On Error Resume Next" line, I get the following error:

Run-time error '1004':
Cannot rename a sheet to the same name as another sheet, a referenced object library or a workbook referenced by Visual Basic

I am using Microsoft Excel 2010. Any help would be greatly appreciated!