【发布时间】:2019-02-08 22:10:38
【问题描述】:
我试图让这段代码找到 V 列不等于“Y”或“L”且 A 列不为空的行。我觉得我做得有点过头了,我确信有一种更简单的方法可以检查行上的两个单元格。
Sub EndMove()
Dim Col1 As Integer, Col2 As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String, currentRowValue2 As String
Col1 = 22
Col2 = 1
rowCount = Cells(Rows.Count, Col1).End(xlUp).row
For currentRow = 1 To rowCount
currentRowValue = Cells(currentRow, Col1).Value
If currentRowValue <> "y" Or currentRowValue <> "l" Then
currentRowValue2 = Cells(currentRow, Col2).Value
If Not IsEmpty(currentRowValue2) Then
Cells(currentRow, Col1).Select
MsgBox "Move this?"
End If
End If
Next
结束子
谢谢
【问题讨论】:
-
找到数据后,您想对它做什么?即,数一下?总结一下?返回一个值?
-
我需要选择A列中的单元格然后调用一个子。
-
@Bofett 也许您应该更多地解释一下您的代码的用途(可能还有其他子代码)。您不需要
Select我评论中所述的任何内容。很有可能,您只是使用Select作为中间运算符。你已经在这里找到了你的问题的答案,所以你的下一个问题应该得到一个新的问题。 -
@urdearboy,你是对的。感谢您的帮助,这很完美。如果需要,我将处理该部分并开始一个新问题。