我对VBA编程很陌生,对这段代码有一些问题..这是为了检查,是否存在一个储存场所,以及这个地方是否有分配给它的物品。它已经起作用了,但是现在它不会做‘如果单元格(I,5).Text是什么’,因此GoTo线跳进来。
如果单元格(i,5).Value也不起作用。
任何帮助都很感激。
Dim x As String
Dim z As String
Dim i As Integer
Tabelle3.Activate
x = InputBox("Please insert the storage place, that is to be emptied")
Cells(3, 2) = x
i = 1
On Error GoTo Ende
Do Until ActiveSheet.Cells(i, 5) = x Or i = 10 'i=amount of available storage places
i = i + 1
Loop
On Error GoTo Ende
If Cells(i, 5).Text Is Nothing Then
Exit Sub
ElseIf ActiveSheet.Cells(i, 6).Value Is Nothing Then
MsgBox "This storage place has no article in it!"
Exit Sub
Else
z = ""
Cells(i, 6) = z
MsgBox "Emptying the storage place " & ActiveSheet.Cells(i, 6) & " was successfull"
End If
Ende:
If Err.Number Then
MsgBox "This storage place doesn't exists or was entered incorrectly"
End If
End Sub发布于 2014-09-04 08:53:39
Is Nothing是用于对象的。
如果要检查单元格是否为空,则可以
If Len(cells(1,1)) = 0 then
或
If IsEmpty(cells(1,1)) then
或
If cells(1,1) = vbNullString
和!
请小心使用.Text属性,因为如果您在单元格中有日期或数字,且列宽较低,且内容不适合并显示##,则.Text将返回##而不是实际值。所见即所得
https://stackoverflow.com/questions/25661057
复制相似问题