aggiungere fogli



  • aggiungere fogli
    di salvo18 (utente non iscritto) data: 10/04/2015 16:00:50

    ho un codice per aggiungere fogli in coda al mio documento. ma non mi funziona. mi da errore 1004. Grazie per l'aiuto
     
    ublic Sub test()
    Dim i, t As Integer
    
    t = Sheets("country").Range("a" & Rows.Count).End(xlUp).Row
    MsgBox t
    
    Dim ws As Worksheet
    'Set ws = ThisWorkbook.Sheets("Sheet1")
    'ws.Name = Sheets("Sheet1").Range("a2").Value
    
    
    For i = 2 To 10
    
    'mainWB.Sheets.Add(After:=mainWB.Sheets(mainWB.Sheets.Count)).Name = Sheets("Foglio2").Range("a" & i).Value
    
    
    Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
    ws.Name = Sheets("country").Range("a" & i).Value
    
    
    Next
    
    End Sub



  • di Lucas87 data: 10/04/2015 16:30:40

    Ciao
    L'errore compare quando esegui 2 volte il codice e il motivo è che vengono creati 2 fogli con lo stesso nome.



  • di salvo18 (utente non iscritto) data: 10/04/2015 16:44:32

    grazie mille! Non sono inoltre permessi i ":" e più di 31 caratteri nel nome del foglio.