TheRedCardinal
Board Regular
- Joined
- Jul 11, 2019
- Messages
- 243
- Office Version
- 365
- 2021
- Platform
- Windows
Hi all,
I am trying to move a table from one worksheet to a predefined worksheet in another, loaded worksheet.
However I can't get it to work without breaking all the speed rules around selecting, activating, pasting etc.
I have added the relevant code here:
I had to expand all these lines - for example, when I tried to use something like this:
I get the run time error telling me the object doesn't support this property or method.
I've literally had to go through and select pasting cells, activate them, switch workbooks etc to make this work which seems unwieldy to me.
Any tips?
Thanks!
I am trying to move a table from one worksheet to a predefined worksheet in another, loaded worksheet.
However I can't get it to work without breaking all the speed rules around selecting, activating, pasting etc.
I have added the relevant code here:
VBA Code:
Dim Parent As String, Filename As String, Path As String
Path = Application.ActiveWorkbook.Path & "\..\"
Set WBk1 = ThisWorkbook
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
Set WBk2 = Workbooks.Open("Link to source file")
Set WS1 = WBk1.Sheets("2. Final Data")
Set WS2 = WBk2.Sheets("2. Imported Data")
WS2.Cells.Clear
WS2.Range("A1").Select
WBk1.Activate
WS1.Activate
WS1.Range("Final_Table[#All]").Select
Selection.Copy
WBk2.Activate
WS2.Activate
WS2.Paste
ActiveWorkbook.SaveAs Filename:=Path & "\" & Filename
ActiveWorkbook.Close
Application.DisplayAlerts = True
WBk1.Activate
End If
I had to expand all these lines - for example, when I tried to use something like this:
VBA Code:
WS1.Range("Final_Table[#All]").Copy
WS2.Range("A1").Paste
I get the run time error telling me the object doesn't support this property or method.
I've literally had to go through and select pasting cells, activate them, switch workbooks etc to make this work which seems unwieldy to me.
Any tips?
Thanks!