title: Create new sheets from a column of cells while avoiding duplicates
body: <p>I have several long columns of data that needs to be sorted. In the first column i have the names of the sheets. But there are several duplicates in there that give me an error message as each sheet needs a unique name. The second and all other columns are to be distributed among the sheets but so far that is not my worry as I can't make the first part not give me an error message. It works fine until it hits a duplicate entry.</p>
  <pre><code>    Dim lastRow As Long
      Dim sheetname As Variant
      Dim sheetexists As Boolean
      Dim cellname As Variant
      Dim worksheet_count As Integer
         
      Dim mysheet As Worksheet
      
          'Find the last non-blank cell in column A1
          lastRow = Cells(Rows.Count, 1).End(xlUp).Row
      
      For i = 2 To lastRow
          worksheet_count = ActiveWorkbook.Worksheets.Count
          sheetexists = False
          For j = 1 To worksheet_count
              sheetname = Cells(i, 1).Value
              cellname = Sheets(j).Name
              If cellname = sheetname Then
                  sheetexists = True
                  a = 5
                  Exit For
              End If
          Next j
                  
          If sheetexists = False Then
              'create sheet, rename sheet
                  
              Worksheets(1).Select
              sheetname = Cells(i, 1).Value
              Sheets.Add After:=Sheets(Sheets.Count)
              ActiveSheet.Name = sheetname
          End If
      Next i
  </code></pre>