sunstache32
New Member
- Joined
- Aug 17, 2015
- Messages
- 5
As part of a larger macro, I have a working piece of code that opens a new workbook, copies the first sheet of that workbook, pastes the sheet into a new sheet of the original workbook, then closes the opened workbook. I want to change this to allow the user to choose which sheet to copy (instead of just the first). Is it possible to do this? Here is the code that copies the first sheet:
Code:
Dim wb_mainFile As Workbook
Dim strMainFile As String
strMainFile = Range("G4").value
'G4 is the cell that has the path for the workbook to open
Set wb_mainFile = Workbooks.Open(strMainFile)
ThisWorkbook.Activate
wb_mainFile.Sheets(1).Copy _
After:=wb3.Sheets(wb3.Sheets.Count)
ActiveSheet.Name = "Sheet3"
wb_mainFile.Close