Sheet

Copper Contributor

I'm wodering if its possible to create one new sheet for (in my case) 220 rows (its a name for each row) in a simpel way. Or do i have to do it manualy one by one?

1 Reply

Hi @Kderiksson 

 

You have data in 220 rows, and you want to create a sheet that named with each row, is that what you want?

If so, you can use this vba code, look at the attached photosheets.png

 

Sub AddSheets()
'Updateby Extendoffice
    Dim xRg As Excel.Range
    Dim wSh As Excel.Worksheet
    Dim wBk As Excel.Workbook
    Set wSh = ActiveSheet
    Set wBk = ActiveWorkbook
    Application.ScreenUpdating = False
    For Each xRg In wSh.Range("A1:A220")
        With wBk
            .Sheets.Add after:=.Sheets(.Sheets.Count)
            On Error Resume Next
            ActiveSheet.Name = xRg.Value
            If Err.Number = 1004 Then
              Debug.Print xRg.Value & " already used as a sheet name"
            End If
            On Error GoTo 0
        End With
    Next xRg
    Application.ScreenUpdating = True
End Sub