Hi, I am trying to copy data between 2 open workbooks. In the code below, the target workbook has the path with the named file. Is it possible to have the "set wb2" refer to the target file in the same directory as the source file? I am asking because we have several users on different computers using this macro so it can't refer to a specific user in the path. If not, the other option is not to refer to a specific target file and just refer to the 2nd open workbook. This would be fine too.
Instead of specifying the range as "C24:I500", can you revise it to C24 to last row with data? If the last row part requires that I copy each column on it's own that would be fine. I will be duplicating the copy and paste for many ranges in the sheet once I get this working.
Also, is the below code the written the best way? I guess we are using the clipboard to copy and paste but I guess it would be better to copy and paste directly. But I do need to keep the formatting from the source to the target.
Thanks
Instead of specifying the range as "C24:I500", can you revise it to C24 to last row with data? If the last row part requires that I copy each column on it's own that would be fine. I will be duplicating the copy and paste for many ranges in the sheet once I get this working.
Also, is the below code the written the best way? I guess we are using the clipboard to copy and paste but I guess it would be better to copy and paste directly. But I do need to keep the formatting from the source to the target.
Thanks
VBA Code:
Sub copyrange4()
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ActiveWorkbook
'Copy what you want from workbook 1.
wb1.Worksheets("QUOTE").Range("C24:I500").Copy 'Change worksheet
'Open workbook 2
Set wb2 = Workbooks.Open("C:\Users\Steve\Desktop\Dropbox\Quotes Steve\QuoteProgram2")
'Paste to worksheet in workbook2:
Application.DisplayAlerts = False
wb2.Sheets("QUOTE").Range("C24").PasteSpecial
Application.CutCopyMode = False
Range("A1").Select
Application.DisplayAlerts = True
End Sub