PDA

View Full Version : Copy from a single cell to a merged cell



staffordalex
11-10-2008, 04:08 AM
Hi,

My code falls over when it tries to copy data from a single cell to a merged cell.

I was hoping someone might be able to shed a bit of light on the matter.

Here's my code:


ActiveSheet.Range("C10").Copy wb.Sheets("WorkstreamReport").Range("B15:C15")


C10 is a single cell
B15 is merged with C15

Thanks,
Alex

GTO
11-10-2008, 04:42 AM
Greetings Alex,

My bet is that you just want the value there, and are hanging up because Excel is trying to paste one cell to two. To just get the value there, try:

wb.sheets("WorkstreamReport").Range("B15:C15")=ActiveSheet.Range("C10")

or:

wb.sheets("WorkstreamReport").Range("B15")=ActiveSheet.Range("C10")

...will also work, as only one cell, the upper-left one, in a "merged cell" holds the value far as I know. (Basically a merged cell doesn't really mean the other cells ceased to exist, they're just vanished so-to-speak. A weak explanation, but hopefully of help.)

Hope this helps,

Mark

Bob Phillips
11-10-2008, 05:05 AM
I don't get a problem. Is the target cell(s) on a protected worksheet?

staffordalex
11-10-2008, 06:37 AM
cheers GTO, works fine!