![]() |
|
#1
|
|||
|
|||
|
The below code copies data from one workbook to another very nicely. But how to copy the same formatting as well.
Code:
Public Sub CopyValues()
Dim wb_src As Workbook
Dim wb_dst As Workbook
Dim ws_src As Worksheet
Dim ws_dst As Worksheet
Set wb_src = Workbooks.Open("C:\Users\User-005\Desktop\a.xlsx")
Set wb_dst = Workbooks.Open("C:\Users\User-005\Desktop\b.xlsx")
Set ws_src = wb_src.Sheets(1)
Set ws_dst = wb_dst.Sheets(1)
Dim data() As Variant
Dim r_src As Range
Dim r_dst As Range
Set r_src = ws_src.Range("A1").Resize(1000, 6)
Set r_dst = ws_dst.Range("A1").Resize(1000, 6)
data = r_src.Value2
r_dst.Value2 = data
End Sub
|
|
#2
|
|||
|
|||
|
Use copy and paste. Arrays don't hold formatting.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Copy from one workbook to another | MartinExcel11 | Excel Programming | 1 | 03-28-2017 09:49 AM |
| automatically copy FIRST COLUMN ONLy to all sheets in workbook | nrcahill | Excel | 1 | 03-14-2016 12:26 PM |
| data entered in one workbook should be updated in other relevant workbook based on the date | vedha | Excel | 0 | 04-24-2015 08:45 PM |
Is it possible to copy and migrate custom views from one XLS workbook to another?
|
JustJeff | Excel | 1 | 12-19-2014 10:11 AM |
macro to transfer data from one workbook to another workbook
|
virsojour | Excel Programming | 5 | 02-01-2011 08:58 PM |