+ Reply to Thread
Results 1 to 2 of 2

Merging data from different excel sheets into one new sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    07-13-2011
    Location
    France, Lille
    MS-Off Ver
    Excel 2007
    Posts
    1

    Merging data from different excel sheets into one new sheet

    Hi,
    I want to merge data from different sheets.
    I've come across several problem and i have done some "work" on it, but i'm unable to go further in the resolution of my problem.

    Here is the code that i've made and that is working for now
    Sub CLEANUP()
    For i = 3 To Sheets.Count
        Worksheets(Worksheets(i).Name).Select
        Cleanuptmp = iFindRowDat(Worksheets(Sheets(1).Name).Cells(1, 1).Value, Worksheets(i).Name)
        'Supprime les lignes jusqu'a ce que la premiere lignes soit celle contenant le header du tableau utile
        While Cleanuptmp <> 1
            Cells(Cleanuptmp - 1, 1).EntireRow.Delete
            Cleanuptmp = iFindRowDat(Worksheets(Sheets(1).Name).Cells(1, 1).Value, Worksheets(i).Name)
        Wend
        'Supprime les premieres colonnes si elles sont vident
        While Cells(1, 1).Value = ""
            Cells(1, 1).EntireColumn.Delete
        Wend
        'Supprime la ligne blanche entre le header et les données du tableau
        While Cells(2, 2).Value = ""
        Cells(2, 2).EntireRow.Delete
        Wend
    Next i
    End Sub
    
    'Trouver la derniere ligne utilisée dans un page
    Function LastRow(WorksheetName As String) As Long
            With Worksheets(WorksheetName)
                On Error Resume Next
                LastRow = .Cells.Find("*", .Cells(1), xlFormulas, xlWhole, xlByRows, xlPrevious).Row
                If Err <> 0 Then xlLastRow = 0
                End With
    End Function
    'Trouver la colonne contenant data, renvoit le numéro de colonne
    Function iFindColDatN(Data As String, WorksheetName As String) As Integer
        Worksheets(WorksheetName).Select
        t = 1
        While Cells(1, t) <> Data
            t = t + 1
        Wend
    End Function
    'Trouver la colonne contenant data, renvoit la lettre de la colonne
    Function iFindColDatL(Data As String, WorksheetName As String) As String
            iFindColDatL = ColLet(iFindColDatN(Data, WorksheetName))
    End Function
    'Converti numéro de colonne en nom de colonne
    Function ColLet(ColNum As Integer) As String
            If ColNum > 26 Then
                'Colonne multi lettre
                ColLetr = Chr(Int((ColNum - 1) / 26) + 64) & Chr(((ColNum - 1) Mod 26) + 65)
            Else
                'Colonne mono lettre
                ColLet = Chr(ColNum + 64)
            End If
    End Function
    'Trouve le numéro de ligne contenant l'information DATA (pour incrémentation et recoupement ultérieur)
    Function iFindRowDat(Data As String, WorksheetName As String) As Integer
            Worksheets(WorksheetName).Select
            On Error Resume Next
            iFindRowDat = Cells.Find(Data).Row
            If Err <> 0 Then iFindRowDat = 0
            While 1 <> 0
            
            
            
    End Function
    I've joined the output that i want, the code that i've mentionned above would be ran from the first page, that will contains some options if needed, and some information regarding the macro usage.

    If anyone could help, this would be great.
    thx in advance,
    Regards,
    MrCarembole.
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Merging data from different excel sheets into one new sheet

    Hi MrCarembole

    Your code appears to be working
    Here is the code that I've made and that is working for now

    You say
    I've come across several problem and i have done some "work" on it, but I'm unable to go further in the resolution of my problem
    You've not described your problem. So...what is the problem????
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1