因此,对于我的代码,我不明白为什么在尝试执行此循环后,我的电子表格无法响应。
函数inpolygon(point, range)
是一个点(2个单元格如此(1,2))是否适合由n乘2范围构成的区域。
任何想法都会非常感激。
Public Function whichplay2(point As range, basinrange As range) As String
Dim nbasin As Integer
Dim i As Integer
i = 1
'number of basins = CInt(basinrange.Columns.Count) / 2
nbasin = CInt(basinrange.Columns.Count) / 2
Do While i <= nbasin
If InPolygon(point, range(basinrange.range("A1").Offset(0, 2 * i - 2), _
basinrange.range("A1").Offset(0, 2 * i - 1).End(xlDown))) = False Then
Else
whichplay2 = Sheets("RawCoor").range("A1").Offset(0, 2 * i - 2)
End If
Loop
End Function
答案 0 :(得分:0)
尝试在循环之前添加i=i+1
,或者:
For i = 1 To nbasin
*rest of code*
Next i