您的位置首页百科知识

运行时错误9 下标越界

运行时错误9 下标越界

的有关信息介绍如下:

运行时错误9 下标越界

可能是单元格的文本没有那么多行,超过了。修改为,如果调用时的参数Line超过了单元格的文本行数,则返回空的字符串。Function GetCellTextLine(i As Integer, j As Integer, Line As Integer) Dim S$, V S = Cells(i, j).Text V = Split(S, Chr(10)) If Line > UBound(V) + 1 Then GetCellTextLine = "" Else GetCellTextLine = V(Line - 1) End IfEnd Function