Excel VBA - Comment réaliser une consolidation de plusieurs feuilles avec une macro

This video will show you how to merge or combine multiple sheets into a new sheet using a VBA procedure. VBA Code: 'Declaring Variables at the Module Level Dim i As Integer, j As Integer, k As Integer Dim LastRow As Integer Dim LastRowConsolidation As Integer '****************************************************** ' Procedure for clearing consolidation data ' to avoid duplicates '****************************************************** Sub ClearConsolidation[] 'Go to the Consolidation sheet Worksheets["Consolidation"].Select 'Select the range corresponding to the data to be cleared Rows["6:1000000"].Select 'Clear the content and formatting Selection.Clear 'or Selection.delete shift:=xlUp 'Go back to the first record to be copied Range["A6"].Select End Sub '******************************************************* ' Procedure for performing a consolidation ' or summary on another sheet. ' ***************************************************** Sub Consolidate[] 'Disable flickering screen refresh Application.ScreenUpdating = False 'Call the procedure to clear the data ClearConsolidation 'Create a loop to read all the sheets to be consolidated 'Here we have 12 sheets from January to December For j = 1 To 12 'Iterate through the first 12 sheets 'Select the first sheet Sheets[j].Select 'Go to the last non-empty row LastRow = Range["A1000000"].End[xlUp].Row 'Iterate through the entire table starting from row to copy each row For i = 6 To LastRow 'Select the first sheet Sheets[j].Select 'Select the first row Rows[i].Select 'Copy the row Selection.Copy 'Where, on the consolidation sheet, it must be selected Sheets["Consolidation"].Select 'Find the last non-empty row in the consolidation sheet LastRowConsolidation = Range["A1000000"].End[xlUp].Row + 1 'Select the empty cell and the first column Cells[LastRowConsolidation, 1].Select 'Once positioned, paste the data ActiveSheet.Paste Application.CutCopyMode = False Next i Next j 'Re-enable screen refresh (flickering) Application.ScreenUpdating = True 'Display a message warning that the consolidation is complete MsgBox "The consolidation is complete...", vbOKOnly + vbInformation, "Message" End Sub ================================================== Visit my Online Store: https://learnaccess.kneo.me/shop ========================================================= ********************************************************************************************************* Use my referral link to purchase a Tesla product and get free credits: Free Supercharger miles Clothing and accessories. https://ts.la/jeanpaul673722 *********************************************************************************************************************