Public Function GetRowToWriteOn(ByVal SheetName As String, ByVal id As Integer) As Integer
LastRow = ActiveSheet.UsedRange.Rows.Count
myarray = Sheets(SheetName).Range("d7:d" & LastRow).Value
For row = 1 To UBound(myarray, 1)
If (myarray(row, 1) = id) Then
Return row
End If
Next
End Function
IDE 说预期的语句结束,我该怎么做?(返回 id 相同的行?)
我对 VBA 一点也不熟悉,但是当我从微软看这个例子时,这应该可以吗?:
Return 语句同时分配返回值并退出函数。以下示例显示了这一点。
Function myFunction(ByVal j As Integer) As Double Return 3.87 * j End Function