我的代码的目的是打印仅当存在betweeen L1任何数据长度7.错误在VBA代码
的W1000虽然它发现长度为7的值,我的代码不服从出口对于。
是什么原因?
Private Sub CommandButton1_Click()
Dim Prod As Variant
Dim Dev As Variant
Dim counter As Integer
Dim j As Variant
Prod = Array("PBA_100", "PCA_500", "PRD_500", "PGA_500", "PVD_500")
For j = LBound(Prod) To UBound(Prod)
MsgBox Prod(j)
With ThisWorkbook.Sheets(Prod(j))
LastRow = ThisWorkbook.Sheets(Prod(j)).Columns("A").Cells.Find("*",
SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious).Row
For Each cell In .Range("N2:N" & LastRow)
arr = Split(Replace(cell.Value, " ", " "), " ")
For Each arrElem In arr
If Len(arrElem) = 7 Then
MsgBox arrElem
Exit For
Else
MsgBox arrElem
End If
Next arrElem
Next cell
End With
Next j
End Sub
哪里定义了k? –
k被定义在顶部 我只包括我有问题的部分。 –