Note: The other languages of the website are Google-translated. Back to English
Se connecter  \/ 
x
or
x
S’enregistrer  \/ 
x

or

Comment fusionner ou consolider des feuilles de calcul ou des classeurs en une seule feuille de calcul?

Dans notre travail quotidien, nous pouvons rencontrer un problème qui fusionne des centaines de feuilles ou de classeurs en une seule feuille pour analyser les données, ce qui prend beaucoup de temps si vous utilisez la commande Copier et coller dans Excel. Ici, dans ce tutoriel, je vais fournir quelques conseils pour résoudre rapidement ce travail.

doc combiner 1

NAVIGATION RAPIDE

Fusion de toutes les feuilles du classeur actif en une seule feuille avec VBA
Fusion de dizaines de feuilles ou de classeurs en une seule feuille de calcul / classeur en quelques clics
Fusion de deux tables en une seule et mise à jour par colonne en quelques clics
Télécharger un exemple de fichier


Fusion de toutes les feuilles du classeur actif en une seule feuille avec VBA

Dans cette section, je fournis un code VBA qui créera une nouvelle feuille pour collecter toutes les feuilles du classeur actif pendant que vous l'exécutez.

1. Activez le classeur que vous souhaitez combiner toutes ses feuilles, puis appuyez sur + clés pour ouvrir Microsoft Visual Basic pour applications fenêtre.

2. Dans la fenêtre contextuelle, cliquez sur insérer > Module pour créer un nouveau script de module.

3. Copiez le code ci-dessous et collez-le dans le script.

Sub Combine()
'UpdatebyExtendoffice
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
doc combiner 2

4. presse F5 clé, alors toutes les données des feuilles ont été fusionnées dans une nouvelle feuille nommée Combinée qui est placée au début de toutes les feuilles.


pas bouger

Voulez-vous avoir une augmentation de salaire et beaucoup de temps pour accompagner votre famille?

Office Tab améliore votre efficacité de 50% dans Microsoft Office en cours de fonctionnement

Incroyable, travailler sur deux documents ou plus est plus facile et plus rapide que travailler sur un seul.

Comparé aux navigateurs bien connus, l'outil à onglets d'Office Tab est plus puissant et plus efficace.

Réduisez les centaines de clics de souris et de saisie au clavier chaque jour pour vous, dites au revoir à la main de la souris maintenant.

Si vous travaillez habituellement sur plusieurs documents, Office Tab vous fera gagner du temps.

Essai gratuit 30-day, Pas de carte de crédit nécessaire.

En Savoir PlusGratuit Télécharger maintenant


Fusion de dizaines de feuilles ou de classeurs en une seule feuille de calcul / classeur en quelques clics

Avec VBA, vous pouvez uniquement combiner des feuilles dans le classeur actif, mais comment fusionner des feuilles de classeurs dans une feuille ou un classeur?

Fusionner les feuilles de tous les classeurs en une seule feuille
doc combiner 18

Fusionner des feuilles de classeurs dans un seul classeur
doc combiner 3

Pour résoudre ce travail et satisfaire d'autres exigences sur la combinaison de Combiner La fonction a été développée avec quatre scénarios de combinaison:

  • Combinez plusieurs feuilles ou classeurs en une seule feuille
  • Combinez plusieurs feuilles ou classeurs dans un seul classeur
  • Combinez les feuilles de même nom en une seule feuille
  • Consolider les valeurs des feuilles ou des classeurs dans une seule feuille

Voici la deuxième option comme exemple:

Combinez plusieurs feuilles ou classeurs dans un seul classeur

Après installation gratuite Kutools for Excel, procédez comme suit:

1. Activez Excel, cliquez sur Kutools Plus > Combiner, une boîte de dialogue apparaît pour vous rappeler que les classeurs que vous souhaitez combiner doivent être fermés. Cliquez sur OK continuer.
doc combiner 4
doc combiner 5

2. dans le Combiner les feuilles de travail étape 1 boîte de dialogue, vérifier Combinez plusieurs feuilles de calcul de classeurs dans un seul classeur option. Cliquez sur Suivant pour passer à l'étape suivante de l'assistant.
doc combiner 6

3. Cliquez Add > Déposez le or Dossier pour ajouter les classeurs que vous souhaitez combiner au Liste des classeurs volet, vous pouvez alors spécifier quelle feuille de calcul sera jointe en vérifiant les noms dans Liste des feuilles de travail vitre. Cliquez sur Suivant pour passer à la dernière étape de l'assistant.
doc combiner 7

4. Dans cette étape, spécifiez les paramètres dont vous avez besoin. Puis clique finition.
doc combiner 8

5. Une fenêtre apparaît pour vous permettre de sélectionner un dossier pour placer le classeur combiné, puis cliquez sur .
doc combiner 9

Maintenant, les classeurs ont été fusionnés en un seul classeur. Et au début de toutes les feuilles, une feuille principale nommée Kutools for Excel est également créée, qui répertorie certaines informations sur les feuilles et les liens de chaque feuille.
doc combiner 10

Démo: combinez des feuilles / classeurs en une seule feuille ou un classeur

Kutools for Excel: 200 + outils pratiques utiles, simplifiant les tâches compliquées dans Excel en quelques clics.

Dites adieu à la main de souris et à la spondylose cervicale maintenant

300 outils avancés de Kutools for Excel résolvent 80% des tâches Excel en quelques secondes, vous sortent des milliers de clics de souris.

Gérez facilement 1500 scénarios de travail, pas besoin de perdre de temps à rechercher des solutions, ayez beaucoup de temps pour profiter de votre vie.

Améliorez la productivité de 80% pour plus de 110000 personnes très efficaces chaque jour, vous y compris bien sûr.

Ne plus être tourmenté par les formules douloureuses et le VBA, donnez à votre cerveau une humeur de travail reposante et joyeuse.

Essai gratuit de 30 jours avec toutes les fonctionnalités, remboursement de 30 jours sans raison.

Un corps meilleur crée une vie meilleure.


Fusion de deux tables en une seule et mise à jour par colonne en quelques clics

Si vous souhaitez fusionner deux tables en une seule et mettre à jour les données en fonction d'une colonne comme illustré ci-dessous, vous pouvez essayer le Fusionner les tables utilité de Kutools pour Excel.
doc combiner 11

Kutools for Excel: plus de 200 compléments Excel pratiques pour simplifier les tâches complexes en quelques clics dans Excel

Après installation gratuite Kutools for Excel, procédez comme suit:

1. Cliquez Kutools Plus > Fusionner les tables autoriser Fusionner les tables Assistant.
doc combiner 12

2. À l'étape 1 de l'assistant, vous devez sélectionner séparément la table principale et les plages de table de recherche. Puis clique Suivant.
doc combiner 13

3. Cochez la colonne clé sur laquelle vous souhaitez mettre à jour les données dans la table principale. Cliquez sur Suivant.
doc combiner 14

4. Vérifiez ensuite les colonnes de la table principale pour lesquelles vous souhaitez mettre à jour les données en fonction de la table de recherche. Cliquez sur Suivant.
doc combiner 15

5. À l'étape 4 de l'assistant, vérifiez les colonnes que vous souhaitez ajouter de la table de recherche à la table principale. Cliquez sur Suivant.
doc combiner 16

6. Dans la dernière étape de l'assistant, spécifiez les options de configuration dont vous avez besoin. Puis clique finition.
doc combiner 17

Maintenant, la table principale a été mise à jour les données et ajouter de nouvelles données basées sur la table de recherche.

Démo: combinez des feuilles / classeurs en une seule feuille ou un classeur

Kutools for Excel: 200 + outils pratiques utiles, simplifiant les tâches compliquées dans Excel en quelques clics.


Télécharger un exemple de fichier

échantillon


Outils de productivité recommandés

Onglet Office - Navigation par onglets, modification, gestion des documents dans Microsoft Office 2019-2003 et Office 365


onglet bureau

Un complément professionnel pour accélérer Excel 2019-2007, réduire les heures de tâches à quelques secondes

Ce complément comprend des dizaines de groupes professionnels, avec plus de 300 options automatisera la plupart de vos tâches quotidiennes dans Excel et augmentera votre productivité d'au moins 50%. Tels que des groupes d'options en un clic et des conversions par lots.
C'est maintenant votre chance de vous accélérer avec Kutools for Excel!


Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    AJIT DIXIT · 11 months ago
    In combining shhets I want to add one extra column in combined sheet as ShhetName
    Can you suggest ?
    • To post as a guest, your comment is unpublished.
      Sunny · 11 months ago
      The Combine function of Kutools for Excel can help you to insert sheet name in a new row of each combined range in the combined sheet by checking First row of each range (new row) in Insert worksheet information section in the last step of the Combine.
  • To post as a guest, your comment is unpublished.
    Eben · 1 years ago
    Hi - this function works well except my file has more than 900 sheets, and when I change the maximum number of rows (Loc 16, "A65536") to a higher number, the macro doesn't work. Is there a way to increase the number of rows that can be shown on the combine sheet?
  • To post as a guest, your comment is unpublished.
    Charlotte · 1 years ago
    The VBA code works fine but I want the data to be merged horizontally(side by side).
    Hope you can help.
  • To post as a guest, your comment is unpublished.
    Daniel · 1 years ago
    Hi,


    Great Code and for the most part it works fantastically well.


    Could I suggest creating a written tutorial for each line of code. I'd love to be able to play around with it to suit my Company's needs.

    In the meantime however could you talk me through problems that would hinder this code from copying all data from each Sheet? I've noticed some sheets in my workbook aren't being copied at all.

    To give you some context I'm dealing with roughly 330 sheets and they hold from 50 to 500 lines in each.


    looking forward to hearing from you.
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Hi, Daniel, I do not understand your question as you describe it not clearly, but if you have the Combine function in Excel, it can solve most of your question about combining sheets.
  • To post as a guest, your comment is unpublished.
    HS · 1 years ago
    Hi,

    Is it possible to only copy a particular range of cells for example A:4:FU38 from each sheet?


    Also in the Combined sheet where the data is copied to, can the tab names from where the data is copied included in column A to enable lookups or to pivot the data?


    Finally, can i specify the list of worksheets from which to copy the data across or maybe i can specify something like copy all worksheets to the left of a particular worksheet in the file.


    Thanks in advance for your help
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Hi, HS, you mean to combine same ranges from sheets into one sheet, it that right? If so, this article may help you: https://www.extendoffice.com/documents/excel/2754-excel-combine-ranges-from-different-worksheets-into-one.html#a3
  • To post as a guest, your comment is unpublished.
    Dennis · 2 years ago
    This VBA code is an absolute lifesaver. Thank you!!
  • To post as a guest, your comment is unpublished.
    martinoreilly · 2 years ago
    Hi. This code works well but I have the same problem as adj. The 1st row form each tab doesn't appear in the combined tab - except he first tab. Thanks
    • To post as a guest, your comment is unpublished.
      Pete · 11 months ago
      Just delete "Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select" from the code.

      If you want to merge all rows from all worksheets, just use the code:

      Sub Combine()
      'UpdatebyExtendoffice
      Dim J As Integer
      On Error Resume Next
      Sheets(1).Select
      Worksheets.Add
      Sheets(1).Name = "Combined"
      Sheets(2).Activate
      Range("A1").EntireRow.Select
      Selection.Copy Destination:=Sheets(1).Range("A1")
      For J = 2 To Sheets.Count
      Sheets(J).Activate
      Range("A1").Select
      Selection.CurrentRegion.Select
      Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
      Next
      End Sub
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Yes, the code only can keep first row of the first tab, because it is used to consolidate, if you want to keep all contents of each sheet, you can try Combine utility of Kutools for Excel, it is free fior 60 days
  • To post as a guest, your comment is unpublished.
    elok · 2 years ago
    i had a problem when I try to combine all same name worksheet to one worksheet, it works but some value are missing. so what should i do?
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Hello, elok, did the problem appear while you applying Combine function? If so, please go to contact us support@extendoffice.com to describe the problem with more details, our support will handle the problem for you.
  • To post as a guest, your comment is unpublished.
    Andrew · 2 years ago
    Thanks that macro saved my day. I had over 40 sheets of data to combine into one and although my computer bogged for a minute or two, it completed without issue. The only modification I made was I tweaked the macro to start with A2 instead of A1 since A1 was my column headers.
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Thanks for your support, Andrew, I am glad that the macro can help you.
  • To post as a guest, your comment is unpublished.
    thangaraj571@gmail.com · 2 years ago
    hi I would like combine all the worksheets in single sheet where i need data of column A of all worksheets and I need the worksheet names in column B
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Sorry, Thangaraj R, I do not undertsand your problem clearly, could you upload a screenshot to describe your quetion with more detials?
  • To post as a guest, your comment is unpublished.
    Gio · 2 years ago
    Hi all,
    I need to combine only sheets with identical heading, ship other sheets.


    thanks
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Sorry, I do not understand your problem clearly, do you mean to combine sheets with same column header? If so, this article may help you.

      https://www.extendoffice.com/documents/excel/3252-excel-merge-excel-files-same-header.html
  • To post as a guest, your comment is unpublished.
    arul.annalect@gmail.com · 3 years ago
    Hi all,

    I have used the below mentioned code, In my data some blank Rows is there for each tab. Data is not coping after the blank rows. How to combine the all data after the blank rows. Please advise.

    Sub Combine()
    Dim J As Integer
    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add
    Sheets(1).Name = "Combined"
    Sheets(2).Activate
    Range("A16").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A17").Select
    Selection.CurrentRegion.Select
    Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub

    Thanks
    Arul
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      You can try below code, it will merge all data and skip blank rows.

      Sub CombineForm()
      Dim xI, xMax As Integer
      Dim xCWS, xWS As Worksheet
      Dim xObjRRange, xObjCRange, xObjSR As Range
      On Error Resume Next
      Sheets(1).Select
      Set xCWS = Worksheets.Add
      xCWS.Name = "Combined"
      Sheets(2).Activate
      Range("A1").EntireRow.Select
      Selection.Copy Destination:=xCWS.Range("A1")
      For xI = 2 To Sheets.Count
      Set xWS = Sheets(xI)
      xWS.Activate
      Set xObjRRange = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
      Set xObjCRange = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
      Set xObjSR = Range(Cells(1, 1), Cells(xObjRRange.Row, xObjCRange.Column))
      xObjSR.Select
      Selection.Copy Destination:=xCWS.Range("A65536").End(xlUp)(2)
      Next
      xMax = xCWS.Range("a65536").End(3).Row
      xCWS.Range("a1:a" & xMax).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
      End Sub
      • To post as a guest, your comment is unpublished.
        arul.annalect@gmail.com · 2 years ago
        Thank you, Sunny! This coding is working fine..

        But i want to combine all the sheets from row no: 16. Could you help us to update the coding.

        Thanks
        Arul
        • To post as a guest, your comment is unpublished.
          Sunny · 2 years ago
          The below code will combine sheets from the second row, you can change the number 2 (xStart = 2) to other number for you need.

          Sub CombineForm()
          Dim xStart, xFNum, xIntCFMax, xIntRRg, xIntCRg As Integer
          Dim xCFWS, xWS As Worksheet
          Dim xObjSR As Range
          Dim xStrName As String
          On Error Resume Next
          Application.ScreenUpdating = False
          xStart = 2
          xStrName = "CombinedForm"
          Set xWS = Sheets(xStrName)
          If xWS Is Nothing Then
          xWS.Delete
          End If
          Set xCFWS = Worksheets.Add
          xCFWS.Name = xStrName

          For xFNum = 1 To Sheets.Count
          Set xWS = Sheets(xFNum)
          If xWS.Name <> xStrName Then
          xWS.Activate
          xIntRRg = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
          xIntCRg = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
          If xStart <= xIntRRg Then
          Set xObjSR = Range(Cells(xStart, 1), Cells(xIntRRg, xIntCRg))
          xObjSR.Select
          Selection.Copy Destination:=xCFWS.Range("A65536").End(xlUp)(2)
          End If
          End If
          Next
          Application.ScreenUpdating = True
          End Sub
      • To post as a guest, your comment is unpublished.
        arul · 2 years ago
        Thank you, Sunny!

        I want to combine the sheet from row no:16. Could you help me to update the coding.

        Thanks
        Arul
  • To post as a guest, your comment is unpublished.
    neno · 3 years ago
    My headings start on row 26, the first 25 rows are occupied with the parameters I used to generate my reports, it would take a long time to delete these since there are many reports generated. Using the VBA code above, how could I configure this code to exclude the first 25 rows, capture the headings on row 26 and combine all the data under the headings (row 27 onwards) for each worksheet?
    • To post as a guest, your comment is unpublished.
      Bruno G. · 3 years ago
      Change all the "A1" in the code to "A26". Save your data before trying this change, just in case!
  • To post as a guest, your comment is unpublished.
    Tina · 3 years ago
    Hi.. The VBA code works fine. Thank you! But can you please help on how I can edit the code so that only 2 sheets will be combined? I have 5 sheets in my workbook but I only need to combine 2 of them.
    • To post as a guest, your comment is unpublished.
      Nigah · 3 years ago
      Just save as the current workbook with a new name and delete other three worksheets which you don't want to combine, now you have only your desired two sheets for VBA code execution.
  • To post as a guest, your comment is unpublished.
    deepak · 3 years ago
    hello everyone

    I want to merged more workbook data in one so give me suggest
  • To post as a guest, your comment is unpublished.
    · 3 years ago
    Hi everyone,

    First of all I have to tell that I have no experience with Macro (VBA Codes). However what I need is related to this. Maybe you guys could help me with it.

    I have a workbook and in this workbook there are 10 worksheets. The first 9 Sheets have the same order of the coloumns of titles and in these columns there are names, dates, percentages of Project Status, comments to Projects etc.. As I said the columns have the same order just the name of the worksheets (for different Teams in the Organisation) are different.

    In Addition to this I have to merge all the worksheets and have them in another sheet which is called "Übersicht" (Overview). However there is a different column in the sheet and it's between "Nr." and "Thema" columns (which are in A1 and A2 in all the 9 Sheets) and this different column called "Kategorie" (in A2 in Übersicht-Overwiev sheet). As this column is between These the order is like this "Nr. (A1), Kategorie (A2) and Thema (A3).....".So this category column (Kategorie) should be empty except this all the Information should be merged into this sheet. And also when there is a Change or update in any worksheet, the Information in "Übersicht" (Overview) sheet needs to update by itself. How can I do this?

    P.S.: Every sheet has different filled rows, some 30, some 13, some 5 etc. And the Teams which are responsible for the Sheets can add or delete some rows (in each row there is different Information for different Projects). This also means the number of rows can increase or decrease.

    I hope I explained it well. Thanks a lot in advance!

    I wish you merry Christmas and a happy new year!

    oduff
  • To post as a guest, your comment is unpublished.
    hk · 3 years ago
    The VBA code works fine but I want the data to be merged horizontally(side by side).
    Hope you can help.
  • To post as a guest, your comment is unpublished.
    Jeanette · 3 years ago
    THANK YOU for the VB Code. Amazing. Worked perfectly. I had 72 worksheets to combine into one. It took a second and it was done. YOU ROCK.
  • To post as a guest, your comment is unpublished.
    Yohani · 3 years ago
    Excellent code! Worked very well!
  • To post as a guest, your comment is unpublished.
    Jonas · 3 years ago
    Hello!
    I need your support. I have three sheets (A, B, C) into a worksheet. the sheet contain information on individuals.
    Sheet A: contains all individuals considered as ID with information (age, education, etc...)
    Sheets B et C: contain some individuals (ID) with information (Organisation, income, etc...)
    So I want to combine B and C to A to get all information from A,B, C together.

    Jonas
  • To post as a guest, your comment is unpublished.
    Jennifer · 3 years ago
    Thank you so very much! The code worked perfectly! I appreciate the instruction so very much!!!
  • To post as a guest, your comment is unpublished.
    Gary · 3 years ago
    Hello, this worked fine at first, but now I see that not all rows from all worksheets are appended into the combined sheet. Please help!
  • To post as a guest, your comment is unpublished.
    Suzana · 3 years ago
    Oh dear! Thank you so MUCH. Worked PERFECTLY with the Code. Had trouble and was thinking how to resolve this and then...just in a second! Thank you a lot. God bless you!
  • To post as a guest, your comment is unpublished.
    adj · 3 years ago
    This code works for the most part - however, the first line of each sheet (except for the first sheet) is not extracted into the combined sheet. Which piece of the code should be modified to ensure extraction of the first line?
  • To post as a guest, your comment is unpublished.
    mario · 3 years ago
    You rock guys!
  • To post as a guest, your comment is unpublished.
    s · 3 years ago
    You guys are the best!!! You totally saved me and I look like a super star
  • To post as a guest, your comment is unpublished.
    Daniel · 3 years ago
    THANK YOU SO MUCH!!!!!
  • To post as a guest, your comment is unpublished.
    Mohd · 3 years ago
    How to merge multiple workbooks with multiple worksheets into one workbook?
  • To post as a guest, your comment is unpublished.
    Mohd · 3 years ago
    [quote name="John"], how to merge multiple workbooks with multiple worksheets into one workbook? appriciate if you could reply.
  • To post as a guest, your comment is unpublished.
    John · 4 years ago
    This is amazing. Thank you so much!
  • To post as a guest, your comment is unpublished.
    Jens · 4 years ago
    When installed, Excel 365 gives a memory error and nothing works.
    I had to uninstall kutools to be able to work again :-(
  • To post as a guest, your comment is unpublished.
    Rich Thorpe · 4 years ago
    Thanks for the help on combining worksheets. Saved me hours of mind numbing work!
  • To post as a guest, your comment is unpublished.
    Ryan · 4 years ago
    how do i get the macro to insert column "a" and paste the name of the workbook the data came from in the added column
  • To post as a guest, your comment is unpublished.
    astu · 4 years ago
    it works so well for my case.
    million thanks for sharing!!!!
  • To post as a guest, your comment is unpublished.
    Raymundo · 4 years ago
    It works, Thaaaanks!
  • To post as a guest, your comment is unpublished.
    Charul · 4 years ago
    can you please explain me the meaning of [b]Selection.Copy Destination:=Sheets(1).Range(" A65536").End(xlUp)(2)[/b] line?What is A65536 used for?
  • To post as a guest, your comment is unpublished.
    Yogesh · 4 years ago
    How to overwrite the updated data over existing data
  • To post as a guest, your comment is unpublished.
    Diane · 4 years ago
    Attempted VBA Code. Have 5 worksheets in 2 workbook that need to be combined. All same structure. VBA code will only combine 2 of the worksheets rather than all 5. What do I change in the VBA code to make combine all 5 worksheets? Data in worksheets is all under the 65K .xls row limit and I am using Excel 2016.
  • To post as a guest, your comment is unpublished.
    Elvedin · 4 years ago
    I receive spreadsheets where table header is in starts in row 3. So I need to go to each worksheet to delete columns 1 and 2 for the macro to work. Can I adjust the code, so it would start in A3 instead of A1
  • To post as a guest, your comment is unpublished.
    boopathi raj · 4 years ago
    Very much Thanks ... ... :lol:
  • To post as a guest, your comment is unpublished.
    CRG · 4 years ago
    [quote name="Nat"]When using the VBA providied above, is there a way for the combined sheet to automatically update when the sheets that is combined are added to it, so it is always running?

    Thanks![/quote]
    Would like to know the answer to this. Thanks for the great Macro!
  • To post as a guest, your comment is unpublished.
    angry_banana · 4 years ago
    Hi! Can you help me with this problem.
    I have an excel doc with 12 sheets. In each sheet is a table. With a differend cells format (width & height).
    I have to copy all sheets in one and save each cells format. Thanks!
  • To post as a guest, your comment is unpublished.
    Kayla · 4 years ago
    Your macro worked BUT it added each sheet multiple times. i have no idea why...I had 4 sheets with invoice lists (1 septembers, 2 octobers Ect.)
    and for some reason it added my september back on 2 more times and added eachother one underneath 3x each....
    I did not modify or delete anything from the macro just simply copied pasted and ran it...
  • To post as a guest, your comment is unpublished.
    GeneA · 4 years ago
    For those people who want to update data they already merged you can use this code:

    Sub Combine()
    Dim J As Integer
    On Error Resume Next
    'Delete the sheet "Combined" if it exist
    Application.DisplayAlerts = False
    On Error Resume Next
    ActiveWorkbook.Worksheets("Combined").Delete
    On Error GoTo 0
    Application.DisplayAlerts = True

    Sheets(1).Select
    Worksheets.Add
    Sheets(1).Name = "Combined"
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub


    ----------------------------------

    Hope that helps!!!!
  • To post as a guest, your comment is unpublished.
    Kabir Humayun · 4 years ago
    How can i collect specific cells data from around 400 sheet... where all sheet are same format.

    for ex. I want to get data from A3, A4, A29, B30, C34 and store on a new sheet.

    thanks in advanced.
  • To post as a guest, your comment is unpublished.
    Kabir Humayun · 4 years ago
    1st thanks for the code,
    I modified the code following way,
    Sub Combine()
    Dim J As Integer
    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add
    Sheets(1).Name = "Combined"
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(0, 0).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(3, 0).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("B65536").End(xlUp)(2)
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(115, 5).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("E65536").End(xlUp)(2)
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(116, 5).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("F65536").End(xlUp)(2)

    Next
    End Sub

    When i tried with this code only around 5/10 sheet, it works fine, but when i tried this code for around 400 sheets then got 2 wrong value and after 255 row no data come for only one column.

    Another columns data are okey and came.

    any idea, basically i need to call data (from some specific cell) from around 400 sheets any idea ?
  • To post as a guest, your comment is unpublished.
    Chandra Mouli · 4 years ago
    Excellent Job ....buddy u have refine my 1 hour ....
    THANKS
  • To post as a guest, your comment is unpublished.
    Martin · 4 years ago
    When I try to use this VBA, it caps out at 79,160 lines (including header). Any suggestions on how to tweak the code or could it be the data in the spreadsheets.
  • To post as a guest, your comment is unpublished.
    Lloyd · 4 years ago
    I am using the VBA below with great effect with all the sheets in workbook but now I am trying to exclude one sheet name " OAL Index" and just cant seemed to get it right. It keeps selecting all the sheets

    Any points to the right direction would be appreciated.

    Sub Combine()
    Dim J As Integer

    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add ' add a sheet in first place
    Sheets(1).Name = "Combined"

    ' copy headings
    Sheets(2).Activate
    Range("A2").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A2")

    ' work through sheets

    For J = 2 To Sheets.Count ' from sheet 2 to last sheet
    If Sheets(J).Name "OAL Index" Then Sheets(J).Select Replace:=False
    Sheets(J).Activate ' make the sheet active
    Sheets(J).Select
    Range("A1").Select
    Selection.CurrentRegion.Select ' select all cells in this sheets

    ' select all lines except title
    Selection.Offset(2, 0).Resize(Selection.Rows.Count - 1).Select

    ' copy cells selected in the new sheet on last line
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub



    Thanks All
  • To post as a guest, your comment is unpublished.
    Jennifer · 4 years ago
    This worked great, saved me a lot of time, but it only merged up to column J and I need it to go up to column T. Can someone please help??? This is for my job!!
    Please help me not look dumb in front of my boss, thanks