【问题标题】:Getting Right Cell Name of current Cell VBA excel获取当前单元格VBA excel的正确单元格名称
【发布时间】:2014-11-17 07:52:43
【问题描述】:

我有当前单元格名称,例如B7 我想获取当前单元格的单元格名称,例如在这种情况下,结果将是C7。我怎样才能做到这一点 这是我累了,但它不起作用

CellName = "B7"
ValueCellName = Right(Range(CellName)).name

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    尝试使用偏移功能:

    valuecellname = Range(cellname).Offset(0, 1).Address
    

    【讨论】:

    • + 1 回答 OP 的实际问题 :)
    【解决方案2】:

    这是你正在尝试的吗?

    Sub Sample()
        Debug.Print GetrightCell("B7")
        Debug.Print GetrightCell("XFD7")
        Debug.Print GetrightCell("ADIL1234")
    End Sub
    
    '~~> Function returns the right cell if there is one!
    Function GetrightCell(CellName As String) As String
        On Error GoTo Whoa
    
        If Range(CellName).Column <> Columns.Count Then
            GetrightCell = Range(CellName).Offset(0, 1).Address
        Else
            GetrightCell = "There are no more cells to the right of this cell"
        End If
        Exit Function
    Whoa:
        GetrightCell = "Invalid Cell Name"
    End Function
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 2013-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多