PDA

View Full Version : Extract single row from multiple workbooks



niss3
01-30-2018, 09:42 AM
Hey! Im in need of some VBA knowledge and would really appriciate some help!

What Im trying to do is a sub program that fetches 7 .csv files and copies B:Y from every one of these 7 workbooks where A1 = "OP0165-IN" (variates from row 19-21, but is never more than 1 row). They all have 1 sheet but the sheet names variates wildely.

I would like to add the data to my sheet "data" from A1 and onwards.

I have some basic VBA knowledge, so I think Im on the correct path with something like this:



Sub GetFile()Dim MySummary As Workbook
Dim GetfilesfromMultiplebooks As Workbook
Dim fd As FileDialog
Dim oFD As Variant
Dim fileName As String


Set fd = Application.FileDialog(msoFileDialogFilePicker)


With fd
.ButtonName = "Select"
.AllowMultiSelect = True
.Filters.Add "Excel Files", "*.csv", 1
.Title = "Select all 7 CSV files"
.InitialView = msoFileDialogViewDetails
.Show
For Each oFD In .SelectedItems
fileName = oFD
Next oFD
On Error GoTo 0
End With


If fd.SelectedItems.Count = 0 Then


Exit Sub

End If


-For each code here?-

End Sub

I think this is one way of doing it. But I havnt really figured out how to extract the data (if I even have the data). Ive been reading examples with "for each workbook". But I couldnt get it to work properly.

If you could help me with this I would be incredible grateful! Thank you very much!!

jolivanes
01-30-2018, 01:04 PM
Did you read the comments in the other forums where you posted the same question?
It's all about cross posting and being polite.

niss3
01-30-2018, 01:14 PM
Did you read the comments in the other forums where you posted the same question?
It's all about cross posting and being polite.

It wasn't my intention to be unpolite. If I found a solution I would have been sure to share it.
If the comments you're refering to are the ones you have written. Yes I have seen them now.

I am not allowed to post links in this forum:

To be able to post links your post count must be 5 or greater. Your post count is 1 momentarily.