PDA

View Full Version : Dierctly copying a cell that might be merged



N35t0r
10-21-2008, 07:42 AM
Hello,


In a Macro I've made, I need to copy a heading from another workbook. I'm using the following code:


Workbooks("Workbook").ActiveSheet.Cells(1, 1).Copy
Cells(1, 1).Select
.Paste


I'm sure the workbook is open.

My problem is that, if cell A1 is merged with another, then nothing is copied. I could forcibly de-merge all headings, or merge them and copy both cells, but I'm sure there must be a.. less invasive method of doing it.

Any ideas?

Thanks!

N35t0r
10-21-2008, 11:50 AM
OK, I've solved it by copying the entire row, but it's of course a workaround.

Thanks anyway!

mdmackillop
10-21-2008, 04:35 PM
Try

Workbooks("Workbook").ActiveSheet.Cells(1, 1).MergeArea.Copy Cells(1, 1)