Hi all,
Hopefully this will be an easy one for you guys although I can't find a solution anywhere. I have a simple macro which imports various data from RAW excel files and cleans it into a separate excel sheet.
Sub importpart2()
Application.ScreenUpdating = False
'' SETUP
Dim DestWB As Workbook: Set DestWB = ActiveWorkbook
Dim UserChoice
DestWB.Worksheets("Data").Activate
Range("A3").Select
Dim LastLine As Long
LastLine = Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row
'' OPEN FILE
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to import", _
FileFilter:="Excel Files *.xlsx (*.xlsx),")
If FileToOpen = False Then
MsgBox "No file specified."
Exit Sub
Else
Workbooks.Open Filename:=FileToOpen
End If
Dim SrcWB As Workbook
Set SrcWB = Application.Workbooks.Open(FileToOpen)
The macro itself works fine. However I want the FILE NAME of the excel sheet i'm importing to be put into a cell. To make things easy just to be placed into cell A1. Is this possible?
Thanks for your time
Hopefully this will be an easy one for you guys although I can't find a solution anywhere. I have a simple macro which imports various data from RAW excel files and cleans it into a separate excel sheet.
Sub importpart2()
Application.ScreenUpdating = False
'' SETUP
Dim DestWB As Workbook: Set DestWB = ActiveWorkbook
Dim UserChoice
DestWB.Worksheets("Data").Activate
Range("A3").Select
Dim LastLine As Long
LastLine = Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row
'' OPEN FILE
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to import", _
FileFilter:="Excel Files *.xlsx (*.xlsx),")
If FileToOpen = False Then
MsgBox "No file specified."
Exit Sub
Else
Workbooks.Open Filename:=FileToOpen
End If
Dim SrcWB As Workbook
Set SrcWB = Application.Workbooks.Open(FileToOpen)
The macro itself works fine. However I want the FILE NAME of the excel sheet i'm importing to be put into a cell. To make things easy just to be placed into cell A1. Is this possible?
Thanks for your time