VBA单元格(i,5).Text
我是新来的VBA编程,并得到了一些问题,这个代码..它是检查,存储的地方是否存在,如果这个地方有一个文章分配给它..它已经工作,但现在不会做'如果单元格(i,5).Text是Nothing“,因此GoTo行跳转
如果Cells(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
Is Nothing
是对象。
如果你想检查一个单元格是否是空的,你可以
If Len(cells(1,1)) = 0 then
要么
If IsEmpty(cells(1,1)) then
要么
If cells(1,1) = vbNullString
和!
请小心使用.Text
属性,因为如果您在单元格中有例如date或数字,并且列宽度较低且内容不适.Text
显示##
则.Text
将返回##
而不是实际值。 所见即所得