Private Function GetLastSameRow(ByVal row, initialValue) As Integer
.
.
.
If (nextCell.Value = initialValue) Then
GetLastSameRow = GetLastSameRow(row + 1, initialValue)
End If
MsgBox ("returning : " & row)
GetLastSameRow = row
End Function
完成if語句後,行爲真的很奇怪。Excel VBA返回行爲奇怪,跳回
我跑它的調試器,這是它一跳:
1. End If '
2. MsgBox ("returning : " & row) ' row value is 3
3. GetLastSameRow = row '
4. MsgBox ("returning : " & row) ' row value is 2 ????????
5. GetLastSameRow = row '
所以基本上它要返回correct
值,但隨後跳回到End if
,並得到來自出藍色correct-1
值。
它是遞歸的事實不是問題嗎? – psubsee2003 2013-02-23 09:55:31