Consulting

Results 1 to 2 of 2

Thread: VBA Conditional formatting - multiple adjacent cells if specific text on left

  1. #1
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    1
    Location

    VBA Conditional formatting - multiple adjacent cells if specific text on left

    If a cell contains "z" then highlight the 3 cells to the right of it. Example If C4=z then C4, D4, E4, F4 turn yellow. J5=z then J5, K5, L5, M5 turn yellow. For my application I need to use VBA not regular conditional formatting.
    Last edited by Terrific; 02-13-2020 at 01:46 PM.

  2. #2
    Knowledge Base Approver VBAX Guru
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    4,840
    A really lazy (=inefficient) way:
    Sub blah()
    For Each cll In ActiveSheet.UsedRange
      If cll.Value = "z" Then cll.Resize(, 4).Interior.Color = vbYellow
    Next cll
    End Sub
    p45cal - - - - -This is my signature, it appears after all my posts. Below is not directed at anyone in particular - so don't take offence! - (You might guess why it's there though)
    If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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