Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am assuming that you are copying data from a source data workbook into a
template that happens to have some cells that are merged for some purpose. Experiment with the MergedCells (Boolean) and MergeArea (Range) properties of a cell on the "Copy to" worksheet. They will tell you if the destination cell has been merged with other cells or not. Step through the code below and inspect the Locals window to see how it works. Check Excel Visual Basic Help also. When a cell has been merged with other cells, then you have to use the MergeArea to copy to, as in the following routine (which assumes both rngFrom and rngTo are single cells). Basically, the value gets put in the upper-left corner cell of the rngTo range, and the other cells in the MergeArea are left empty. Public Sub CopyToMergedCell(rngFrom As Range, rngTo As Range) If rngTo.MergeCells _ Then rngFrom.Copy Destination:=rngTo.MergeArea Else rngFrom.Copy Destination:=rngTo End If End Sub -- Regards, Bill Renaud |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to paste data in new sheet? | Excel Programming | |||
Paste Cells With Data To Another Sheet | Excel Discussion (Misc queries) | |||
Macro to extract data and paste to a new sheet | Excel Programming | |||
Copy and paste data to a new sheet | Excel Programming | |||
Automatically Cut Row of Data and Paste to Other Sheet? | Excel Programming |