How to get find if a cell in excel is merged? If the cell mrged how to read the value?

后端 未结 4 524
日久生厌
日久生厌 2021-01-18 08:20

How do I detect if a cell in excel is merged?

If the cell is merged how do I read the value?

4条回答
  •  心在旅途
    2021-01-18 08:44

    Here's how to read the cell's value in VBA, regardless if it is merged or not.

    C.MergeArea.Cells(1, 1).Value

    where C is the cell you want to look at. The way this works is that the MergeArea is either exactly the same as the cell itself if the cell is not merged; otherwise the MergeArea is the range of cells that have been merged. And when the cells are merged, the value is kept in the topleftmost cell.

提交回复
热议问题