steveh8204
Board Regular
- Joined
- Aug 20, 2018
- Messages
- 151
I read on a website tutorial that a more efficient way of copying and pasting ranges was to use the following:
I was led to believe this way made the code run significantly quicker, the problem I've got though is that I'm copying from a different spreadsheet so I was wondering whether this is still possible to do?
The code I am using to copy and paste is:
With the Macs All.MHTML file being another spreadsheet to the one currently open.
Code:
' This is faster
Range("A1:A10").Value = Range("B1:B10").Value
' This is slower
Range("B1:B1").Copy Destination:=Range("A1:A10")
I was led to believe this way made the code run significantly quicker, the problem I've got though is that I'm copying from a different spreadsheet so I was wondering whether this is still possible to do?
The code I am using to copy and paste is:
Code:
Worksheets("SAP").Activate
Dim wb As Workbook
Dim myfilename As String
myfilename = "P:\PFMSHARE\LOGISTICS\STOCK CHECK DOCUMENTS & BBE CHECKER\Macs Auto Stock Checker\Macs All.MHTML"
Set wb = Workbooks.Open(myfilename)
a = Range("A2:d200").Copy
Workbooks("Macs Auto Stock Check.xlsm").Activate
Range("a3").Select
paste = a
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets(2).Activate
With the Macs All.MHTML file being another spreadsheet to the one currently open.