2
我使用vba宏在some_col
找到一个非空的单元格,从第1行开始。当我找到那个时,我想将它分配到pword
,在相邻列的单元格至cword
。但似乎在运行此代码时,循环并没有终止,因为即使找到非空单元,它也没有结束。 (另外,如果我使用pword = Nothing
则显示类型不匹配错误,并且在msdn网站上,他们将此作为用于空字符串的选项。)
任何人都可以请告诉这里有什么问题吗?
类型不匹配错误与Nothing和循环没有终止
Dim pword As String
Dim cword As String
Dim present_row As Long
pword = ""
Cells(1, some_col).Activate
MsgBox "Active cell: " & ActiveCell.Address
Do
If Not ActiveCell.value = "" Then
pword = ActiveCell.value
cword = ActiveCell.Offset(0, 1).value
End If
ActiveCell.Offset(1, 0).Activate
present_row = ActiveCell.Row
Loop Until pword = ""
@simico其工作:) – Gauranga
@simico你能告诉为什么循环没有结束,为什么调试器指向'ActiveCell.Offset(1 ,0)。激活'? – Gauranga
+ 1 @Downey:把这句话放在'If not ActiveCell.value ='“'之前'pword =”“'然后就可以了 –