Sub SeperateTabs2()
'run from source data sheet
'assumes headers in A1 (ISO) and B1 (URL) and data in cols A:G
'creates URL and No URL sheets for each unique ISO entry
Dim dataSht As Worksheet, R As Range, Iso As Variant, d As Object, c As Range, Temp As Range
Set dataSht = ActiveSheet
Set R = Range("A1:G" & Cells(Rows.Count, "A").End(xlUp).Row)
'get unique list from col A ISOs
Set d = CreateObject("scripting.dictionary")
For Each c In R.Columns(1).Cells
If Not d.exists(c.Value) Then d.Add c.Value, d.Count + 1
Next c
Application.ScreenUpdating = False
For i = 1 To d.Count - 1
R.AutoFilter field:=1, Criteria1:=d.keys()(i)
R.AutoFilter field:=2, Criteria1:="<>"
On Error Resume Next
Set Temp = R.SpecialCells(xlCellTypeVisible)
If Err.Number = 0 Then
Application.DisplayAlerts = False
Sheets(d.keys()(i) & " - URL").Delete
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = d.keys()(i) & " - URL"
Temp.Copy Destination:=ActiveSheet.Range("A1")
End If
Err.Clear
R.AutoFilter field:=1, Criteria1:=d.keys()(i)
R.AutoFilter field:=2, Criteria1:="="
On Error Resume Next
Set Temp = R.SpecialCells(xlCellTypeVisible)
If Err.Number = 0 Then
Application.DisplayAlerts = False
Sheets(d.keys()(i) & " - NoURL").Delete
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = d.keys()(i) & " - NoURL"
Temp.Copy Destination:=ActiveSheet.Range("A1")
End If
Err.Clear
Next i
With dataSht
.Select
.ShowAllData
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub