Sub CopyColsFrom3Wbk()
' nwixx
Dim FNames As Variant
Dim NewSht As Worksheet
Dim Cnt As Long
Dim Valu As Variant
Dim OldCol As Long
Dim NewCol As Long
Dim Arr() As Variant
Application.ScreenUpdating = False
ChDrive "[COLOR=#ff0000]C:[/COLOR]"
ChDir "[COLOR=#ff0000]C:\Users\Fluff\Desktop\test\[/COLOR]"
Arr = Array("[COLOR=#0000ff]Dlow[/COLOR]", "[COLOR=#0000ff]Volume[/COLOR]", "[COLOR=#0000ff]SMA20[/COLOR]")
Do
FNames = Application.GetOpenFilename(FileFilter:="Excel workbooks (*.xls*),*.xls*", Title:="Select 3 files to import", MultiSelect:=True)
If Not IsArray(FNames) Then
MsgBox "You pressed Cancel, Macro will quit"
Exit Sub
ElseIf UBound(FNames) <> 3 Then
MsgBox "You have not selected 3 files." & vbLf & "Use ""Ctrl+left click"" to select 3 files."
End If
Loop Until UBound(FNames) = 3
Workbooks.Add (1)
Set NewSht = ActiveSheet
With NewSht
.Range("A1") = Arr(0)
.Range("B1") = Arr(1)
.Range("C1") = Arr(2)
End With
NewCol = 1
For Cnt = 1 To UBound(FNames)
Workbooks.Open FNames(Cnt)
For Each Valu In Arr
OldCol = Rows(1).Find(Valu).Column
Range(Cells(2, OldCol), Cells(Rows.Count, OldCol).End(xlUp)).Copy _
NewSht.Cells(Rows.Count, NewCol).End(xlUp).Offset(1)
NewCol = NewCol + 1
Next Valu
NewCol = 1
ActiveWorkbook.Close False
Next Cnt
End Sub