Excel VBA根据单元格值选择一个范围
我是VBA新手Excel VBA根据单元格值选择一个范围,excel,vba,Excel,Vba,我是VBA新手 For each cell in columns("c:c") If cell.value = "TRUE" Then 'vba is required for selecting corresponding cells in columns A and B Next cell Else: exit sub End if end sub 请进行适当的更正试试这个: Sub test() Dim lastrow As Long Dim c As Range,
For each cell in columns("c:c")
If cell.value = "TRUE" Then
'vba is required for selecting corresponding cells in columns A and B
Next cell
Else:
exit sub
End if
end sub
请进行适当的更正试试这个:
Sub test()
Dim lastrow As Long
Dim c As Range, rng As Range
'change Sheet1 to suit
With ThisWorkbook.Worksheets("Sheet1")
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Each c In .Range("C1:C" & lastrow)
If UCase(c.Text) = "FALSE" Then
If rng Is Nothing Then
Set rng = .Range("A" & c.Row).Resize(, 2)
Else
Set rng = Union(rng, .Range("A" & c.Row).Resize(, 2))
End If
End If
Next c
End With
If Not rng Is Nothing Then rng.Select
End Sub
到目前为止你尝试了什么?嗨,西米科,请看上面编辑的代码。我只是粗略地写了一篇博文。我对编码不太了解。你想只选择C列中第一行为FASLE,还是选择C列中所有为false的行?我想选择所有包含false的行千行中应该选择哪些列?是的,这是一个完美的选择。这就是我需要的。谢谢西米科。如果你不介意,我可以有你的电子邮件ID,或者除了这个网站,我可以在哪里直接得到你的帮助?