HalifaxFox
New Member
- Joined
- Jul 18, 2011
- Messages
- 2
Hi,
I am fairly new to Non-Recorded Macros.
I have a Test.xls spreadsheet and am trying to create a macro that will select files and sheet names from different Ranges input in that Test.xls file. I want both the files and the specific tabs/worksheets from the files to be variable, and selected from the defined range.
Currently, I have the following code:
varWorkbook = "Variable Workbook Location" & Range("L1").Value
Workbooks.Open varWorkbook
Sheets("Sheet1").Select
Cells.Select
Selection.Copy
Windows("Test.xls").Activate
Sheets("01").Select
Range("A1").Select
ActiveSheet.Paste
The formula works for selecting the custom workbook based on the workbook name I input in cell L1 of Test.xls.
I want to duplicate that for the tab name from the workbook, to replace the Sheets("Sheet1").Select with whatever sheet name I put in, say, cell M1 of the Test.xls workbook.
Any advice would be much appreciated!
I am fairly new to Non-Recorded Macros.
I have a Test.xls spreadsheet and am trying to create a macro that will select files and sheet names from different Ranges input in that Test.xls file. I want both the files and the specific tabs/worksheets from the files to be variable, and selected from the defined range.
Currently, I have the following code:
varWorkbook = "Variable Workbook Location" & Range("L1").Value
Workbooks.Open varWorkbook
Sheets("Sheet1").Select
Cells.Select
Selection.Copy
Windows("Test.xls").Activate
Sheets("01").Select
Range("A1").Select
ActiveSheet.Paste
The formula works for selecting the custom workbook based on the workbook name I input in cell L1 of Test.xls.
I want to duplicate that for the tab name from the workbook, to replace the Sheets("Sheet1").Select with whatever sheet name I put in, say, cell M1 of the Test.xls workbook.
Any advice would be much appreciated!