ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy paste merged cells (https://www.excelbanter.com/excel-programming/428372-copy-paste-merged-cells.html)

Ivano

copy paste merged cells
 
Hi,
The following code gives me "cannot change part of a merged cell" because
each of the rows (H to K) that I am copy/pasting are merged. I have tried
just to use H5:H23 as the range but that didn't work either. Can someone
suggest something?

I have the following code:

Public Sub Sheet1()
Dim srcWb As Workbook
Dim destWb As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim srcRng As Range
Dim destRng As Range

Set srcWb = Workbooks("Source Workbook.xls")
Set destWb = Workbooks("Destination Workbook.xls")
Set srcSH = srcWb.Sheets("Source Worksheet")
Set destSH = destWb.Sheets("Destination Worksheet")

srcSH.Range("H5:K23").Copy Destination:=destSH.Range("H5:K23")

End Sub

Thanks,
Ivano


All times are GMT +1. The time now is 02:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com