您好,欢迎来到中国最大的生活服务网站![登录][注册]
版主:Mniwtian   副版主:
点击查看所有副版主

Range("A1:B2")

To determine if a particular range contains any merged cells, you can use the following VBA function. The function returns True if any cell in the argument range is a merged cell (refer to Chapter 10 for more information about Function procedures).

 

Function ContainsMergedCells(rng As Range)

    Dim cell As Range

    ContainsMergedCells = False

    For Each cell In rng

        If cell.MergeCells Then

            ContainsMergedCells = True

            Exit Function

        End If

    Next cell

End Function

 

To refer to merged cells, you can reference the entire merged range or just the upperleft cell within the merged range. For example, if a worksheet contains four cells merged into one (A1, B1, A2, and B1), reference the merged cells using either of the following expressions:

 

 

Range("A1")

 

If you attempt to assign a value to a cell in a merged range that''s not the upper-left cell, VBA ignores the instruction and does not generate an error. For example, the following statement has no effect if A1:B2 is merged:

 

Range("B2").Value = 43

用户名: 请您登录后再发帖 
标 题: 标题请勿超过30个字
内 容:
 
  请阅读我们的[服务条款]
Copyright © 2009 Yahoo.com.cn 版权所有 不得转载 | 使用须知 | 著作权声明 | 京ICP证000022号 | 国家药监局(京)-经营性-2004-0039
全球阿里巴巴 - 阿里巴巴网络:中国站 国际站 日文站 | 淘宝站 | 支付宝 | 中国雅虎 | 口碑网 | 阿里软件 | 阿里妈妈