I have a little issue with my code. The purpose is to get a specific range of data from each file (F19:F42), and to copy that range to another file's gathering sheet named "Extraction" piece below the previous piece, and form a column with 720/744 rows of data, depending the month.
The issue is that my code didn't copy and paste every single peace of data range below the previous piece of data, as it should be. Constantly copy the data from the last file; replacing the data in Range("A1") of Sheets("Extraction"), instead of forming a column in A . Can you please help me with that one and give me a correction/adding for my code. Thank you in advance!
Here's the code :
The issue is that my code didn't copy and paste every single peace of data range below the previous piece of data, as it should be. Constantly copy the data from the last file; replacing the data in Range("A1") of Sheets("Extraction"), instead of forming a column in A . Can you please help me with that one and give me a correction/adding for my code. Thank you in advance!
Here's the code :
VBA Code:
Sub Extraction()
Dim FileNames As Variant
Dim i As Integer
Application.ScreenUpdating = False
Range("A2").Select
FileNames = Application.GetOpenFilename(FileFilter:="Excel Filter (*csv), *.csv", Title:="OpenFile(s)", MultiSelect:=True)
For i = 1 To UBound(FileNames)
Workbooks.Open FileNames(i)
'Separate
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=";", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1), Array(6, 1)), TrailingMinusNumbers:=True
Range("F19:F42").Select
Selection.Copy
Windows("Wind Energy Monthly Forecast.xlsm").Activate
Sheets("Extraction").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Transpose:=False
Workbooks.Open FileNames(i)
ActiveWorkbook.Close SaveChanges:=False
ActiveCell.Offset(1, 0).Activate
Next i
End Sub