kthevbaamateur
New Member
- Joined
- Jun 21, 2018
- Messages
- 2
Hi
I want to preface this by saying I am a complete vba amateur.
I am trying to make a code that makes a new worksheet for every unique value in column Z. There are a few duplicates. This is what I have so far:
Sub CreateSheets()
'Creates a sheet for each unique Sector name
Dim c As Range, sh As Worksheet
Application.ScreenUpdating = False
With Worksheets("Sheet 2").Activate
For Each c In .Range(.Range("Z2"), .Range("Z" & .Rows.Count).End(xlUp))
Set sh = Sheets.Add(After:=Sheets(Sheets.Count))
sh.Name = c.Value
Set sh = Nothing
Next
End With
Application.ScreenUpdating = True
End Sub
I want to preface this by saying I am a complete vba amateur.
I am trying to make a code that makes a new worksheet for every unique value in column Z. There are a few duplicates. This is what I have so far:
Sub CreateSheets()
'Creates a sheet for each unique Sector name
Dim c As Range, sh As Worksheet
Application.ScreenUpdating = False
With Worksheets("Sheet 2").Activate
For Each c In .Range(.Range("Z2"), .Range("Z" & .Rows.Count).End(xlUp))
Set sh = Sheets.Add(After:=Sheets(Sheets.Count))
sh.Name = c.Value
Set sh = Nothing
Next
End With
Application.ScreenUpdating = True
End Sub