这工作LASTROW = 8,而不是9(类型不匹配)类型不匹配VBA
如果我删除If Not (myarray = Empty) Then
它不会为8
什么是解决这个最简单的方式工作?
Public Function GetRowToWriteOn(ByVal SheetName As String, ByVal idnr As Integer) As Integer
LastRow = (Sheets(SheetName).UsedRange.Rows.Count) + 1
MsgBox (LastRow)
myarray = Sheets(SheetName).Range("d8:d" & LastRow).Value
If Not (myarray = Empty) Then
For row = 1 To UBound(myarray, 1)
If (myarray(row, 1) = idnr) Then
GetRowToWriteOn = row
Exit Function
End If
Next
End If
GetRowToWriteOn = LastRow
Exit Function
End Function
什么是'LastRow'和'row'的价值?想知道你是否超过了整数的限制。 – markblandford
对不起,它实际上是拉斯特罗,它是8和9 –
你是否明确地使用选项? – Trace