
Originally Posted by
princ_wns
How to copy data of merged cells into a cell. How it can be done from VBA.
Your question is kind of vague and lacking in details, but see if this code line addresses your problem. Let's say your merged cells are C2:F3. You can reference that range either in its entirety or by an one or more set of cells within it for this method. So, you could use any one of the following to copy just the value in that merged range to another cell (for my example, I used cell D8 for the destination cell)...
Code:
Range("D8").Value = Range("C2:F3")(1).MergeArea.Value
Code:
Range("D8").Value = Range("E2:D3")(1).MergeArea.Value
Code:
Range("D8").Value = Range("C2")(1).MergeArea.Value
Code:
Range("D8").Value = Range("F3")(1).MergeArea.Value
Code:
Range("D8").Value = Range("D3")(1).MergeArea.Value
All of the above copy just the value in the merged cells C2:F3 into the cell D8. So, using the setup I show above, any cell or cells in the merged area may be used to transfer the value in the merged area to another cell.
Bookmarks