I'm trying to copy a selected piece of data from multiple files (vector) and putting them into another workbook as transposed data.
Here is what I have (In multiple workbooks with different values each)
And Here is what I want to arrange that data into (In one workbook)
Here is my code
Option Explicit
Option Base 1
Sub ArrangeData()
Dim A() As String, nw As Integer
Dim i As Integer, FileNames As Variant
Dim tWB As Workbook, aWB As Workbook
Dim rng As range
Set tWB = ThisWorkbook
MsgBox ("Enter files that you wish to import data from.")
FileNames = Application.GetOpenFilename(FileFilter:="Excel Filter (*.csv), *.csv", Title:="Open File(s)", MultiSelect:=True)
MsgBox ("The first file will now open, Select the rage you wish to import. This range will be imported from each of the files you selected.")
nw = UBound(FileNames)
ReDim A(nw) As String
For i = 1 To nw
If i = 1 Then
Workbooks.Open FileNames(i)
Set aWB = ActiveWorkbook
Set rng = Application.InputBox(Title:="Select Range", Prompt:="Range", Type:=8)
aWB.Close SaveChanges:=False
End If
tWB.Worksheets("Data").range("A"& i) = WorksheetFunction.Transpose(rng)
Next i
End Sub
This does not seem to take each different vectors from other worksheets, but only one vector from the first worksheet. What can I do to make this work?