2014-11-17 134 views

回答

4

尝试使用偏移功能:

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

+ 1解答OP的实际问题:) –

1

这是你想什么呢?

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 
相关问题