Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Highlight Data Based on Data in Another Column

  1. #11
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    Start with this. Put it in the Sheet Example module.
    Since you are not clear about which values have to be changed to what you must adapt the code yourself.
    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$B$1" Then
            FindNr = Sheets("Table").Columns(1).Find(Target.Value, , xlValues, xlWhole).Offset(, 1).Value
            With Sheets("Example")
                For Each cl In .Range("B4:B" & .Cells(Rows.Count, 2).End(xlUp).Row)
                    If cl.Value = FindNr Then
                        cl.Offset(, 1) = IIf(cl.Offset(, 1).Value = "x", "n/a", cl.Offset(, 1).Value)
                        cl.Offset(, 2) = IIf(cl.Offset(, 2).Value = 0, "j/k", cl.Offset(, 2).Value)
                    End If
                Next
            End With
        End If
    End Sub

  2. #12
    Junior Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    Bakerman,

    Per your Code,

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$B$1" Then
            FindNr = Sheets("Table").Columns(1).Find(Target.Value, , xlValues, xlWhole).Offset(, 1).Value
            With Sheets("Example")
                For Each cl In .Range("B4:B" & .Cells(Rows.Count, 2).End(xlUp).Row)
                    If cl.Value = FindNr Then
                        cl.Offset(, 1) = IIf(cl.Offset(, 1).Value = "x", "n/a", cl.Offset(, 1).Value)
                        cl.Offset(, 2) = IIf(cl.Offset(, 2).Value = 0, "j/k", cl.Offset(, 2).Value)
                    End If
                Next
            End With
        End If
    End Sub
    How do I get Excel to recognize this code as a macro? I have enabled excel to allow for all macros in my settings.
    Last edited by Admin; 04-17-2014 at 07:53 AM.

  3. #13
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    As I said earlier >> Put the code in the Sheet Example module not in a normal module.
    As soon as you change B1 in Sheet Eample (confirm with Enter) the code starts automatically.

Similar Threads

  1. Replies: 34
    Last Post: 03-13-2015, 02:26 PM
  2. Replies: 10
    Last Post: 02-18-2014, 01:34 PM
  3. Group And Transpose Data Based On Sections of Data
    By theladysaphir in forum Excel Help
    Replies: 5
    Last Post: 06-28-2013, 07:55 AM
  4. Replies: 17
    Last Post: 05-22-2013, 11:58 PM
  5. Group Pivot Data Based On Row Values In One Column
    By mrmmickle1 in forum Excel Help
    Replies: 10
    Last Post: 10-09-2012, 11:46 PM

Posting Permissions

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