unire foglicsv



  • unire fogli.csv
    di Studio36100 (utente non iscritto) data: 02/01/2014 13:56:20

    Ciao a tutti, ho diversi fogli excel in .csv e devo unirli tra di loro in maniera quasi automatizzata.
    Come posso fare?
    grazie della gentile collaborazione



  • di patel data: 02/01/2014 14:21:14

    spiegare più nel dettaglio, allegare 2 file di esempio ed anche il risultato desiderato





  • di Grograman data: 02/01/2014 14:49:14

    Non so che padronanza tu abbia del VBA quindi mi limito a postare un codice che ho negli appunti che, data una cartella contenente dei files dello stesso tipo, li apre uno dopo l'altro e accoda i dati di un dato range di celle.

    Totalmente da adattare!
     
    ''ACCODA DATI
    Option Explicit
    
    Private Sub Sfoglia_Files()
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''' ATTENZIONE RICHIEDE L'ATTIVAZIONE DELLA LIBRERIA MICROSOFT SCRIPTING RUNTIME '''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        Dim strPath As String
       
        Dim objFSY As FileSystemObject
        Dim objFOL As Folder
        Dim objFIL As File
        
        Dim wbFrom As Workbook, wbTo As Workbook
        Dim wsFrom As Worksheet, wsTo As Worksheet
        Dim x As Long, i As Long
        Dim rngCopy As Range
        
        Set wbTo = ThisWorkbook
        Set wsTo = wbTo.Sheets(1)
         
        strPath = "C:ProveFiles" '''QUI IL PERCORSO
        
        Set objFSY = New FileSystemObject
        Set objFOL = objFSY.GetFolder(strPath)
    
        For Each objFIL In objFOL.Files
    			x = wsTo.Range("B" & wsTo.Rows.Count).End(xlUp).Row + 1
    			
    			Set wbFrom = Application.Workbooks.Open(objFIL)
    			Set wsFrom = wbFrom.Sheets(1)
    				With wsFrom
    					i = .Range("B" & .Rows.Count).End(xlUp).Row
    					Set rngCopy = .Range("B3:Q" & i)
    					rngCopy.Copy wsTo.Cells(x, 2)
    					Set rngCopy = Nothing
    				End With
    			wbFrom.Close 0
    			Set wbFrom = Nothing
    			Set wsFrom = Nothing
        Next
    
        Set objFSY = Nothing
        Set objFOL = Nothing
        Set wbTo = ThisWorkbook
        Set wsTo = Nothing
    End Sub



  • di Grograman data: 02/01/2014 14:50:04

    Uhm.... la tabulazione dell'indent è frutto di un copia e incolla da notepad++ non è quella che gli ho dato io