JohnSawers
New Member
- Joined
- Dec 14, 2012
- Messages
- 4
Hi all.
I have a macro (see code below) that copies a worksheet (Sheet1) from a closed workbook into Sheet1 of the active workbook. So far, so good but I need the path to the closed workbook to be taken from a cell in the active workbook which is populated by a drop-down combo box. I have named cells for all the respective parts of the path such as:
Named Cell = Description Example
Path = Drive & Directory 'C:\Documents\
FileName = File name & extension [FILE.XLSM]
SheetName = Sheet name Sheet1'!
SheetRoute = Path up to sheet name 'C:\Documents\[FILE.XLSM]Sheet1'!
[TABLE="width: 475"]
<colgroup><col width="142"><col width="333"></colgroup><tbody>[TR]
[TD="class: xl65, width: 333"][/TD]
[/TR]
</tbody>[/TABLE]
If anyone has any suggestions on how to address the named cell path (eg to "SheetRoute"), then this would be a great help.
CURRENT MACRO CODE
Sub test()
Dim FileFilter As String
Dim FileName As String
Dim SrcWkb As Workbook
FileFilter = "All Excel Files,*.xla;*.xls;*.xls*;*.xlt,All Files, *.*"
FileName = Application.GetOpenFilename(FileFilter)
If FileName = "False" Then Exit Sub
Set SrcWkb = Workbooks.Open(FileName)
SrcWkb.Sheets(1).UsedRange.Copy ThisWorkbook.ActiveSheet.Range("A1")
SrcWkb.Close False
End Sub
I have a macro (see code below) that copies a worksheet (Sheet1) from a closed workbook into Sheet1 of the active workbook. So far, so good but I need the path to the closed workbook to be taken from a cell in the active workbook which is populated by a drop-down combo box. I have named cells for all the respective parts of the path such as:
Named Cell = Description Example
Path = Drive & Directory 'C:\Documents\
FileName = File name & extension [FILE.XLSM]
SheetName = Sheet name Sheet1'!
SheetRoute = Path up to sheet name 'C:\Documents\[FILE.XLSM]Sheet1'!
[TABLE="width: 475"]
<colgroup><col width="142"><col width="333"></colgroup><tbody>[TR]
[TD="class: xl65, width: 333"][/TD]
[/TR]
</tbody>[/TABLE]
If anyone has any suggestions on how to address the named cell path (eg to "SheetRoute"), then this would be a great help.
CURRENT MACRO CODE
Sub test()
Dim FileFilter As String
Dim FileName As String
Dim SrcWkb As Workbook
FileFilter = "All Excel Files,*.xla;*.xls;*.xls*;*.xlt,All Files, *.*"
FileName = Application.GetOpenFilename(FileFilter)
If FileName = "False" Then Exit Sub
Set SrcWkb = Workbooks.Open(FileName)
SrcWkb.Sheets(1).UsedRange.Copy ThisWorkbook.ActiveSheet.Range("A1")
SrcWkb.Close False
End Sub