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? Commented 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. Commented 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? Commented Mar 25, 2014 at 17:31
  • i want to select all the rows which contain false Commented Mar 25, 2014 at 17:32
  • what columns in thouse rows should be selected? Commented 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
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.