4

I am new to 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

please make suitable corrections

6
  • what ahve you tried so far? Mar 25, 2014 at 17:24
  • hi simico, please look atabove edited code. just i wrote roughly bcoz i dont to know much about coding.
    – ganesh
    Mar 25, 2014 at 17:30
  • you wnat to select only first row where in column C is FASLE, or all rows where in column C is false? Mar 25, 2014 at 17:31
  • i want to select all the rows which contain false
    – ganesh
    Mar 25, 2014 at 17:32
  • what columns in thouse rows should be selected? Mar 25, 2014 at 17:33

1 Answer 1

5

Try this one:

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
1
  • YES its perfect hit. Thats what I needed. thanks simico. If you dont mind can i have your email ID or where can i take your help directly other than this website?
    – ganesh
    Mar 25, 2014 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.