Consulting

Results 1 to 5 of 5

Thread: highlight the row after I input something in column a

  1. #1

    highlight the row after I input something in column a

    Hi,

    I want a macro that can perform the following task.
    Could you please write me the macro?


    Task:


    For each worksheet in the workbook,
    and for each cell in column A,
    after I input something in a cell in column a, the row will be filled by red colour.

    However, if the things in a cell in column a is deleted, the red colour will be removed from that row.

    thanks

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Put this in the ThisWorkbook code module

    [VBA]Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    With Application.Intersect(Target, Sh.Columns(1))
    .SpecialCells(xlCellTypeBlanks).EntireRow.Interior.ColorIndex = xlNone
    .SpecialCells(xlCellTypeConstants).EntireRow.Interior.ColorIndex = 3
    End With
    On Error GoTo 0
    End Sub[/VBA]

  3. #3
    Quote Originally Posted by mikerickson
    Put this in the ThisWorkbook code module

    [vba]Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    With Application.Intersect(Target, Sh.Columns(1))
    .SpecialCells(xlCellTypeBlanks).EntireRow.Interior.ColorIndex = xlNone
    .SpecialCells(xlCellTypeConstants).EntireRow.Interior.ColorIndex = 3
    End With
    On Error GoTo 0
    End Sub[/vba]
    thank you for your reply.

    but there is a problem.

    For example:
    If I input something in cell C5, row 5 will not be filled by red colour.
    However, after I input something in cell A6, then both row 5 and 6 will be filled by red colour.

    If I delete the thing in a6, the red colour on row 6 will be removed.
    However, the red colour in row 5 will not be removed.

    thanks

    thanks

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Quote Originally Posted by clarksonneo

    I want a macro that can perform the following task.

    Task:


    For each worksheet in the workbook,
    and for each cell in column A,
    after I input something in a cell in column a, the row will be filled by red colour.

    However, if the things in a cell in column a is deleted, the red colour will be removed from that row.
    This what you asked for,and that is what Mike kindly gave you.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Another approach would be to put conditional fomatting on all the cells with the formula
    =(LEN($A1)>0)

Posting Permissions

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