ForrestGump01
New Member
- Joined
- Mar 15, 2019
- Messages
- 23
- Office Version
- 365
- Platform
- Windows
Hello all,
Should be a simple piece of code, but I'm getting a timeout error.
I've got a workbook, let's call it "summary", which I want to put a macro in that will open another workbook, select all the data from a specific tab "CFG", and paste it into a tab, of the same name "CFG" within the "summary" workbook. I do not want to copy the entire tab, rather just copy the cells and paste them as values, so that the formulas in the summary workbook still work.
FWIW I will be repeating this multiple times (e.g. there are multiple tabs I'll be copy-pasting, currently just testing it with one tab)
Any help is appreciated.
Here's my code:
Dim my_SourceFile As Variant
Dim my_SummaryFile As Variant
Sub Retrieve_IR()
my_SummaryFile = ThisWorkbook.Name
my_SourceFile = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*")
If my_SourceFile <> False Then
Workbooks.Open Filename:=my_SourceFile
End If
Sheets("CFG").Copy
Workbooks("my_SummaryFile").Activate
Sheets("CFG").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Sub
Should be a simple piece of code, but I'm getting a timeout error.
I've got a workbook, let's call it "summary", which I want to put a macro in that will open another workbook, select all the data from a specific tab "CFG", and paste it into a tab, of the same name "CFG" within the "summary" workbook. I do not want to copy the entire tab, rather just copy the cells and paste them as values, so that the formulas in the summary workbook still work.
FWIW I will be repeating this multiple times (e.g. there are multiple tabs I'll be copy-pasting, currently just testing it with one tab)
Any help is appreciated.
Here's my code:
Dim my_SourceFile As Variant
Dim my_SummaryFile As Variant
Sub Retrieve_IR()
my_SummaryFile = ThisWorkbook.Name
my_SourceFile = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*")
If my_SourceFile <> False Then
Workbooks.Open Filename:=my_SourceFile
End If
Sheets("CFG").Copy
Workbooks("my_SummaryFile").Activate
Sheets("CFG").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Sub