LOGIC:
For each cell in a range(column2)
if cell value = "spare"
do nothing
if not
check whether each cell in range(column7) is empty
if cell is blank do nothing
if not
counter++
有人可以告诉我如何用正确的VBA语法写这个吗? 非常感谢任何帮助/提示 非常感谢你提前:))
答案 0 :(得分:0)
For Each individualMember in MembersCollection
'do something
Next 'individualMember
你的案子:
Dim column2 as Range 'whole column, beware of overhead
Dim cell as Range 'one cell
Set column2 = sheets(1).columns(2)
For Each cell in column2.Cells
If cell.value2 <> "spare" then 'not equal "spare"
'check whether each cell in range(column7) is not empty
If cell.offset(columnoffset:=5).Value2 <> "" then
counter = counter + 1
End If
ElseIf cell.value2 = "spare" And 1+1=2 Then
'do another thing
Else 'all other posibilities
'do yet another thing
End If
Next 'cell