Sheet

%3CLINGO-SUB%20id%3D%22lingo-sub-2006763%22%20slang%3D%22en-US%22%3ESheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2006763%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20wodering%20if%20its%20possible%20to%20create%20one%20new%20sheet%20for%20(in%20my%20case)%20220%20rows%20(its%20a%20name%20for%20each%20row)%20in%20a%20simpel%20way.%20Or%20do%20i%20have%20to%20do%20it%20manualy%20one%20by%20one%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2006763%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2006812%22%20slang%3D%22en-US%22%3ERe%3A%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2006812%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F908541%22%20target%3D%22_blank%22%3E%40Kderiksson%3C%2FA%3E%26nbsp%3BAnd%20where%20would%20the%20names%20come%20from%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2007112%22%20slang%3D%22en-US%22%3ERe%3A%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2007112%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F908541%22%20target%3D%22_blank%22%3E%40Kderiksson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20have%20data%20in%20220%20rows%2C%20and%20you%20want%20to%20create%20a%20sheet%20that%20named%20with%20each%20row%2C%20is%20that%20what%20you%20want%3F%3C%2FP%3E%3CP%3EIf%20so%2C%20you%20can%20use%20this%20vba%20code%2C%20look%20at%20the%20attached%20photo%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22sheets.png%22%20style%3D%22width%3A%20621px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242128iC0292BD8280BB960%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22sheets.png%22%20alt%3D%22sheets.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20AddSheets()%0A'Updateby%20Extendoffice%0A%20%20%20%20Dim%20xRg%20As%20Excel.Range%0A%20%20%20%20Dim%20wSh%20As%20Excel.Worksheet%0A%20%20%20%20Dim%20wBk%20As%20Excel.Workbook%0A%20%20%20%20Set%20wSh%20%3D%20ActiveSheet%0A%20%20%20%20Set%20wBk%20%3D%20ActiveWorkbook%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20For%20Each%20xRg%20In%20wSh.Range(%22A1%3AA220%22)%0A%20%20%20%20%20%20%20%20With%20wBk%0A%20%20%20%20%20%20%20%20%20%20%20%20.Sheets.Add%20after%3A%3D.Sheets(.Sheets.Count)%0A%20%20%20%20%20%20%20%20%20%20%20%20On%20Error%20Resume%20Next%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Name%20%3D%20xRg.Value%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20Err.Number%20%3D%201004%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20Debug.Print%20xRg.Value%20%26amp%3B%20%22%20already%20used%20as%20a%20sheet%20name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20On%20Error%20GoTo%200%0A%20%20%20%20%20%20%20%20End%20With%0A%20%20%20%20Next%20xRg%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

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