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!!
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!!