Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno excel - několik sešitů dohromady

ahoj,

tak zase jeden orisek s excelem. nenapada me zadna moznost jak to udelat automaticky, ale protoze jste mi tu s excelem vzdy pomohli, tak se radsi zeptam. treba bude nekdo vedet.

mam cca 300 sesitu / souboru. v kazdem z nich je list a v nem jsou data. ta data jsou obdobna, to znamena, ze je v kazdem souboru stejny pocet sloupcu a ty maji stejne zahlavi. jedine co je jinak, tak data v radcich a je i ruzny pocet radku.

a ted..

potrebuju mit vsechna ta data v jednom souboru pod sebou. cili, slo by nejak udelat, aby se data nastahovala do jedineho souboru? klidne bych si pak i rucne vyfiltroval zahlavi, to uz by bylo to nejmensi. jedine reseni, ktere napada me je otevrit vsechny soubory a rucne kopirovat. myslite, ze to jde udelat nejak - efektivneji?

diky moc

Předmět Autor Datum
Samozřejmě - místo ručního kopírování vytvoříš makro, které - postupně otevře všechny soubory - z ka…
MachR55 03.12.2014 15:16
MachR55
tak ja s tim nehnu. zkousel jsem si nakopirovat kody a me to bohuzel nefunguje. muzete mi pomoct to… nový
mayerrs 04.12.2014 09:13
mayerrs
Pošli mi klidně do PM třeba deset těch XLS souborů jako vzorek, udělám makro, které pak načte všechn… nový
Moas 04.12.2014 13:45
Moas
diky, davam sem archiv deseti souboru, nejde mi je prilozit do PM a nebo nevim jak na to. nový
mayerrs 04.12.2014 14:26
mayerrs
řešení... nový
Moas 05.12.2014 06:52
Moas
dik:-) maka jak ma:-) poslední
mayerrs 05.12.2014 22:23
mayerrs

tak ja s tim nehnu. zkousel jsem si nakopirovat kody a me to bohuzel nefunguje. muzete mi pomoct to upravit pro me podminky? co jsem naposledy zkousel, tak kod z posledniho odkazu:

_____________________________________

Option Explicit

Sub Auto_open_change()

Dim WrkBook As Workbook
Dim StrFileName As String
Dim FileLocnStr As String
Dim LAARNmeWrkbk As String
Dim rowcounter As Integer

FileLocnStr = "C:\Excel" 'ThisWorkbook.Path

Dim StrFile As String
StrFile = Dir(FileLocnStr & "\*.xls")

rowcounter = 3
Do While Len(StrFile) > 0
Call DoStuff(FileLocnStr & "\" & StrFile, rowcounter)
StrFile = Dir
rowcounter = rowcounter + 1
Loop

End Sub
Private Sub DoStuff(StrFileName As String, rowcounter As Integer)

Workbooks.Open (StrFileName)

Call Edit(rowcounter)

Workbooks.Open (StrFileName)

ActiveWorkbook.Close

End Sub

Sub Edit(rowcounter As Integer)
Dim Wb1 As Workbook
Dim ws1 As Worksheet
Dim loopcal As Long
With Application
.ScreenUpdating = True
.EnableEvents = True
lngCalc = .Calculation
End With

Set Wb1 = ActiveWorkbook
Sheets("1_3 Octave1 CH1").Select
Range("A3:AH3").Select
Selection.Copy

Windows("template.xlsm").Activate
Sheets("Data Extract").Select
Range("B" & rowcounter).Select

'index the variable to ensure the cell reference changes each time.
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

_____________________________________

tenhle kod ma delat tohle:
Merging all Workbooks in a Folder
The following code example creates a new workbook. The code then takes each Excel workbook in the folder C:\Users\Peter\invoices and copies information from cells A9 through C9 into the new workbook. In addition, the code puts the workbook file name in row A.
To loop through all of the files in the folder, use the Dir function. The first time that you call Dir, enter the path of the files that you want as an argument and retrieve the first file. Next, call Dir without arguments, and you retrieve the next file. When there are no more files, the process returns an empty string.

ja bych tam potreboval zapracovat tuhle funkci:

Copying a Range that Extends Down to the Last Row
In the previous examples, you knew exactly which rows to copy. However, you may want to copy cells from a starting row down to the last row where you do not know what row is the last. The following example shows how to modify the code so that the macro copies columns A through K, from row 8 to the last row.
To copy all rows, you first have to find the last row. You can find the last row with the Find method, which returns a range of cells that match a specified criterion. In this case, the code starts at the bottom of the worksheet and searches upward, row-by-row, until the code finds a cell that is not blank. Replace the line that sets the variable SourceRange to the following code example.
VBA
Dim LastRow As Long
LastRow = WorkBk.Worksheets(1).Cells.Find(What:="*", _
After:=WorkBk.Worksheets(1).Cells.Range("A1"), _
SearchDirection:=xlPrevious, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows).Row
Set SourceRange = WorkBk.Worksheets(1).Range("A8:K" & LastRow)

To find any cell that is not blank, set the What argument to the wildcard "*" and the LookIn argument to xlFormulas. To start from the bottom up, set the After argument to the first cell and the SearchDirection argument to xlPrevious, which will cause the search to wrap around to the bottom. To search by rows, set the SearchOrder argument to xlByRows. Finally, use the Row property to find the row number of the last row. Then, use the row number to define a range that starts at A8 and goes to column K and the last row number.
In this case, you know that the last column is K. If you do not know the last column, use the RDB_Last function in Merging Data from Multiple Workbooks into a Summary Workbook in Excel, which can provide the last column, last row, or last cell.

_______________________________

muj adresar je "C:\Excel"

a mam excel 2007

diky moc za pomoc, ja at zkousim jak zkousim (vice mene nevim co presne delam - jen upravuju cestu a snazim se dat range prvnich 500 radku protoze nevim jak udelat range od prvniho do posledniho vyplneneho radku), tak kdyz pak spustim makro, tak se nic nedeje.

jeste jednou diky za pomoc!!

Pošli mi klidně do PM třeba deset těch XLS souborů jako vzorek, udělám makro, které pak načte všechny soubory ve složce a sloučí do jednoho.
Tvůj kód mi přijde jako směska z rekordéru a různé kousky posbírané po webu, což je v zásadě vhodná cesta k učení se, akorát se v tom neorientuju. :)

Zpět do poradny Odpovědět na původní otázku Nahoru