Extragere date din mai multe workbook-uri

Închis
mihainiculae92
Mesaje: 15
Membru din: Vin Sep 16, 2016 1:43 pm

Extragere date din mai multe workbook-uri

Mesaj de mihainiculae92 » Vin Oct 14, 2016 10:04 am

Salut,

Incerc sa fac un fisier excel care sa caute in mai multe fisiere excel un cuvant specific, dupa ce il gaseste sa imi selecteze un tabel format din 50 de randuri si 13 coloane si sa il copieze in fisierul de extragere.
Vreau sa copieze tabelele unul sub altul in fisierul de extragere:

Pana acum am partea asta de cod:

Sub ExtractData2()
Dim SummarySheet As Worksheet
Dim FolderPath As String
Dim SelectedFiles() As Variant
Dim NRow As Long
Dim FileName As String
Dim NFile As Long
Dim WorkBk As Workbook
Dim SourceRange As Range
Dim DestRange As Range
Dim WhatToLook As Variant

'Create a new worksheet and set the name = curent weeknumber

Sheets.Add.Name = Format(Date, "YYWW")
Set SummarySheet = ActiveSheet
' Modify this folder path to point to the files you want to use.
FolderPath = "d:\LocalData\User12\Desktop\RAPURI"
' Set the current directory to the the folder path.
ChDrive FolderPath
ChDir FolderPath
'Open the file dialog box and filter on Excel files, allowing multiple files to be selected.
SelectedFiles = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xl*), *.xl*", MultiSelect:=True)
' NRow keeps track of where to insert new rows in the destination workbook.
NRow = 1
' Loop through the list of returned file names
For NFile = LBound(SelectedFiles) To UBound(SelectedFiles)
' Set FileName to be the current workbook file name to open.
FileName = SelectedFiles(NFile)

' Open the current workbook.
Set WorkBk = Workbooks.Open(FileName)

' Select what to look for
WhatToLook = InputBox("What I'm looking for?", "Hello There", S1642)
SummarySheet.Range("A1").Value = "I'm looking for:"
SummarySheet.Range("B1").Value = WhatToLook.Text

' Cod lipsa




' Increase NRow so that we know where to copy data next.
NRow = NRow + DestRange.Rows.Count

' Close the source workbook without saving changes.
WorkBk.Close savechanges:=False
Next NFile

' Call AutoFit on the destination sheet so that all data is readable.
SummarySheet.Columns.AutoFit

End Sub

Imi lipseste partea cu ce sa caute, selectarea tabelului si copierea acestuia in fisierul de extragere.

Ma puteti ajuta? :roll:

Multumesc frumos!

Închis

Înapoi la “Visual Basic for Application (VBA) cu Excel - Intrebari tehnice”