0
我有当前单元格名称,例如B7
我想获取当前单元格的单元格名称,例如在这种情况下结果将为C7
。我怎样才能做到这一点 这是我累了,但它不工作当前单元格VBA的单元格名称当前单元格的名称excel
CellName = "B7"
ValueCellName = Right(Range(CellName)).name
我有当前单元格名称,例如B7
我想获取当前单元格的单元格名称,例如在这种情况下结果将为C7
。我怎样才能做到这一点 这是我累了,但它不工作当前单元格VBA的单元格名称当前单元格的名称excel
CellName = "B7"
ValueCellName = Right(Range(CellName)).name
尝试使用偏移功能:
valuecellname = Range(cellname).Offset(0, 1).Address
这是你想什么呢?
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
+ 1解答OP的实际问题:) –