Results 1 to 5 of 5

Selecting a Row based on cell value

This is a discussion on Selecting a Row based on cell value within the Excel Questions forums, part of the Question Forums category; I need a macro that will select a row and highlight yellow if the value in coulmn C is a ...

  1. #1
    Guest

    Default

    I need a macro that will select a row and highlight yellow if the value in coulmn C is a particular value. Any ideas?

  2. #2
    New Member
    Join Date
    Feb 2002
    Posts
    10

    Default

    You can use conditional formatting to do this rather than a macro.

    The macro would be something along the lines of

    Sub Macro1()
    '
    '
    For a = 1 To 100
    locatione = "c" & a
    data = Range(locatione).Value
    If data = "x" Then
    locatione = a & ":" & a
    Rows(locatione).Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    End If
    Next
    End Sub

    [ This Message was edited by: bobeuk on 2002-03-05 10:02 ]

  3. #3
    Guest

    Default

    I need a macro, because it is a bit more complicated than what I made it sound like. The only thing I cannot figure out how to handle is selecting the row.

  4. #4
    AJ
    AJ is offline
    Board Regular
    Join Date
    Mar 2002
    Location
    =ActiveCell.Address
    Posts
    478

    Default

    Is this the type of thing your after.
    This would go from cell C1 to whereever data finished in column C and colour every row that had a value of 5 in column C


    --
    myRow = 1
    Lastrow = Range("C65000").End(xlUp).Row
    For i = 1 To Lastrow
    Range("C" & myRow).Select
    If ActiveCell.Value = 5 Then
    Rows(myRow & ":" & myRow).Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    End If
    myRow = myRow + 1
    Next i

    --

    Rgds
    AJ

  5. #5
    AJ
    AJ is offline
    Board Regular
    Join Date
    Mar 2002
    Location
    =ActiveCell.Address
    Posts
    478

    Default

    you can also get the current row into a variable or whatever, at any given point with
    ActiveCell.Row


Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com