Guys, can you help me with code?
I don't understand where mistake is.
Option Explicit
Option Base 1
Sub RalphieReactor()
Dim FileNames() As Variant, i As Integer, S() As Variant, A() As Variant, j As Integer, nw As Integer
Dim twb As Workbook, awb As Workbook, UserRange As Range, ImportRange As String
Set twb = ThisWorkbook
FileNames = Application.GetOpenFilename(Title:="Open File(s)", MultiSelect:=True)
nw = UBound(FileNames)
ReDim S(nw, 4) As Variant
ReDim A(nw, 4) As Variant
For i = 1 To nw
Workbooks.Open FileNames(i)
Set awb = ActiveWorkbook
Set UserRange = Application.InputBox(Prompt:="Range", Type:=8)
ImportRange = UserRange.Address
For j = 1 To 4
S(i, j) = awb.Sheets(1).Range(ImportRange).Cells(i, j)
A(i, j) = S(i, j)
Next j
awb.Close SaveChanges:=False
Next i
twb.Activate
Range("A1:D4") = A
End Sub
So, after start, data was imported incorrect.
фор.PNG
But this screenshot shows the correct imported data.
sOKDvu49EeeFrgryCjqNWg_37e85d2f574f2183de23c99a831f687b_ralphie-reactor-result.png
Bookmarks