Hoppa till huvudinnehåll

Hur slår man samman eller konsoliderar kalkylblad eller arbetsböcker i ett kalkylblad?

I vårt dagliga arbete kan vi stöta på ett problem som slår samman hundratals ark eller arbetsböcker till ett ark för att analysera data som tar mycket tid om du använder kommandot Kopiera och klistra in i Excel. Här i denna handledning kommer jag att ge några tips för att snabbt lösa detta jobb.

doc kombinera 1

SNABB NAVIGATION

Sammanfoga alla ark med aktiv arbetsbok till ett ark med VBA
Slå ihop dussintals ark eller arbetsböcker till ett arbetsblad / arbetsbok med klick
Sammanfoga två tabeller i en och uppdatera med en kolumn med klick
Ladda ner exempelfil


Sammanfoga alla ark med aktiv arbetsbok till ett ark med VBA

I det här avsnittet tillhandahåller jag en VBA-kod som skapar ett nytt ark för att samla alla ark i den aktiva arbetsboken medan du kör den.

1. Aktivera arbetsboken du vill kombinera alla ark och tryck sedan på + nycklar för att öppna Microsoft Visual Basic för applikationer fönster.

2. Klicka på i poppfönstret Insert > Modulerna för att skapa ett nytt modulskript.

3. Kopiera nedanstående kod och klistra in dem i skriptet.

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 kombinera 2

4. Tryck F5 nyckeln, då har all data över ark sammanförts till ett nytt ark med namnet Combined som placeras framför alla ark.


inte flytta

Vill du ha löneförhöjning och mycket tid att följa med familjen?

Fliken Office förbättrar din effektivitet med 50% när Microsoft Office arbetar just nu

Otroligt, att arbeta på två eller flera dokument är enklare och snabbare än att arbeta på ett.

Jämfört med kända webbläsare är flikverktyget i Office-fliken kraftfullare och effektivare.

Minska hundratals musklick och tangentbordstypning varje dag åt dig, säg adjö till mushanden nu.

Om du vanligtvis arbetar med flera dokument kommer Office Tab att vara en bra tidsbesparing för dig.

30- dagars gratis provperiod, inget kreditkort krävs.

Läs merGratis nedladdning nu


Slå ihop dussintals ark eller arbetsböcker till ett arbetsblad / arbetsbok med klick

Med VBA kan du bara kombinera ark i den aktiva arbetsboken, men hur kan du slå samman ark mellan arbetsböcker till ett ark eller en arbetsbok?

Slå samman ark över arbetsböcker till ett ark
doc kombinera 18

Slå samman ark över arbetsböcker till en arbetsbok
doc kombinera 3

För att lösa detta jobb och uppfylla andra krav på ark-kombination, Kombinera funktionen har utvecklats med fyra kombinationsscenarier:

  • Kombinera flera ark eller arbetsböcker till ett ark
  • Kombinera flera ark eller arbetsböcker i en arbetsbok
  • Kombinera samma namnblad till ett ark
  • Konsolidera värden över ark eller arbetsböcker till ett ark

Här tar det andra alternativet som exempel:

Kombinera flera ark eller arbetsböcker i en arbetsbok

Efter gratis installation Kutools för Excel, gör så här:

1. Aktivera Excel, klicka på Kutools Plus > Kombinera, en dialogruta dyker upp för att påminna dig om att arbetsböckerna du vill kombinera behövs stängas. Klick OK att fortsätta.
doc kombinera 4
doc kombinera 5

2. I Kombinera arbetsblad steg 1 dialogrutan, kontrollera Kombinera flera kalkylblad från arbetsböcker till en arbetsbok alternativ. Klick Nästa för att gå till nästa steg i guiden.
doc kombinera 6

3. klick Lägg till > Fil or mapp för att lägga till de arbetsböcker du vill kombinera till Arbetsbokslista i rutan kan du ange vilket kalkylblad som ska sammanfogas genom att kolla in namnen Kalkylbladslista ruta. Klick Nästa för att gå till det sista steget i guiden.
doc kombinera 7

4. I det här steget anger du inställningarna efter behov. Klicka sedan Finish.
doc kombinera 8

5. Ett fönster dyker upp för att du ska välja en mapp för att placera den kombinerade arbetsboken och klicka sedan på Save.
doc kombinera 9

Nu har arbetsböckerna sammanförts till en arbetsbok. Och på framsidan av alla ark skapas också ett huvudark med namnet Kutools for Excel som listar lite information om arken och länkar för varje ark.
doc kombinera 10

Demo: Kombinera ark / arbetsböcker till ett ark eller arbetsbok

Kutools för Excel: 200 + användbara praktiska verktyg som förenklar de komplicerade uppgifterna i Excel med några få klick.

Säg adjö till mushand och cervikal spondylos nu

300 avancerade verktyg av Kutools för Excel lösa 80% Excel-uppgifter på några sekunder, dra dig ut ur tusentals musklick.

Hantera enkelt 1500 arbetsscenarier, du behöver inte slösa tid på att söka lösningar, ha mycket tid att njuta av ditt liv.

Förbättra 80 % produktivitet för 110000 XNUMX+ mycket effektiva människor varje dag, naturligtvis inklusive dig.

Inte längre att plågas av smärtsamma formler och VBA, ge din hjärna en vila och glädjande arbetsstämning.

30 dagars gratis provperiod med alla funktioner, 30 dagars pengarna tillbaka utan anledning.

En bättre kropp skapar ett bättre liv.


Sammanfoga två tabeller i en och uppdatera med en kolumn med klick

Om du vill slå samman två tabeller i en och uppdatera data baserat på en kolumn som visas nedan, kan du prova Tabeller slås samman nytta av Kutools för Excel.
doc kombinera 11

Kutools för Excel: mer än 200 praktiska Excel-tillägg för att förenkla komplicerade uppgifter till några få klick i Excel

Efter gratis installation Kutools för Excel, gör så här:

1. klick Kutools Plus > Tabeller slås samman att möjliggöra Tabeller slås samman guiden.
doc kombinera 12

2. I steg 1 i guiden måste du välja huvudtabell- och uppslagstabellintervall separat. Klicka sedan Nästa.
doc kombinera 13

3. Kontrollera nyckelkolumnen som du vill uppdatera data i huvudtabellen baserat på. Klick Nästa.
doc kombinera 14

4. Kontrollera sedan kolumnerna i huvudtabellen som du vill uppdatera data baserat på uppslagstabell. Klick Nästa.
doc kombinera 15

5. I steg 4 i guiden, kontrollera kolumnerna du vill lägga till från uppslagstabellen till huvudtabellen. Klick Nästa.
doc kombinera 16

6. I det sista steget i guiden anger du inställningsalternativen efter behov. Klicka sedan Finish.
doc kombinera 17

Nu har huvudtabellen uppdaterats och lagt till nya data baserat på uppslagstabellen.

Demo: Kombinera ark / arbetsböcker till ett ark eller arbetsbok

Kutools för Excel: 200 + användbara praktiska verktyg som förenklar de komplicerade uppgifterna i Excel med några få klick.


Ladda ner provfil

prov


Rekommenderade produktivitetsverktyg

Fliken Office - Bläddring, redigering, hantering av dokument i Microsoft Office 2019-2003 och Office 365


Office-fliken

Ett professionellt tillägg för att påskynda Excel 2019-2007, krympa timmar till sekunder

Detta tillägg innehåller dussintals yrkesgrupper, med 300+ alternativ automatiserar de flesta av dina dagliga uppgifter i Excel och ökar din produktivitet med minst 50%. Såsom grupper med ett klick optons och batchkonverteringar.
Nu är det din chans att snabba upp dig själv med Kutools för Excel!


Comments (168)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, I have a system that generates an excel file everyday. The daily file name is of format "<filename-12282021>". The 12282021 is the timestamp and it changes everyday creating a new excel file each day. I want to create a Master Workbook and then append the contents of the daily excel file into that master workbook. How can I automate it so it happens by itself everyday and the master file is update with contents of the daily file.   Thank you.
This comment was minimized by the moderator on the site
Hi rd2022, sorry that I have no idea to solve your problem so far. You can go to our forum https://www.extendoffice.com/forum/excel.html to leave this message, maybe some users have the same problem and has been solved.
This comment was minimized by the moderator on the site
In combining shhets I want to add one extra column in combined sheet as ShhetName
Can you suggest ?
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
The VBA code works fine but I want the data to be merged horizontally(side by side).
Hope you can help.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
This VBA code is an absolute lifesaver. Thank you!!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
Hello, elok, did the problem appear while you applying Combine function? If so, please go to contact us to describe the problem with more details, our support will handle the problem for you.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
Thanks for your support, Andrew, I am glad that the macro can help you.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations