pheeelicxz
New Member
- Joined
- Nov 29, 2018
- Messages
- 2
Hi,
I am trying to import data from multiple workbooks onto this master workbook and then have the imported document name entered onto a list starting vertically from C9.
I have the code to import the files but have not figured out how to get the name of the doc onto the list from C9.
This is what i have got at the moment:
Any help is appreciated.
Many thanks!
I am trying to import data from multiple workbooks onto this master workbook and then have the imported document name entered onto a list starting vertically from C9.
I have the code to import the files but have not figured out how to get the name of the doc onto the list from C9.
This is what i have got at the moment:
Code:
Sub ImportDatafromotherworksheet()
'Activate "Global Spend" worksheet
Worksheets("Global Spend").Activate
Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range
Dim filename As String
Dim xCell As Range
Dim lastRow As Long
Set wkbCrntWorkBook = ActiveWorkbook
lastRow = Range("A" & Rows.Count).End(xlUp).Row
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A2", Type:=8)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A" & lastRow + 1, Type:=8)
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
'Input name of file in list "C9". Header at C9, next entry is one row down.
???
'Go back to "Start" worksheet
Worksheets("Start").Activate
'Confirmation messagebox
MsgBox ("You have successfully imported the file you have choosen. Please check content in 'Global Spend' worksheet.")
End Sub
Any help is appreciated.
Many thanks!