Consulting

Results 1 to 2 of 2

Thread: code to copy content to adjacent cells based on a cell value

  1. #1

    code to copy content to adjacent cells based on a cell value

    I'm looking for a code in certain columns which copies a text to adjacent cells based on a cell value. If a cell in column contains the desired text then 3 adjacent cells to the left of column should also contain the same text

    Attaching my sheet here
    project sheet.xlsx

    If you look at the sheet, Column I, M, Q, U needs to be checked for "Dismissed". If any cell contains dismissed the 4 adjacent cells to left also need to contain "dismissed"

    eg: if M6 is found to contain "Dismissed" then the same needs to be copied to cells J6, K6 and L6

    Any help is appreciated.
    Thanks in advance

  2. #2
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location
    Sub vbax52717()
    ' 5/28/2015 mperrah
    
    Dim r, c, lr As Long
    
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    
    For r = 2 To lr
        For c = 8 To 20 Step 4
            If Cells(r, c) = "Dismissed" Then Cells(r, c).Copy Cells(r, c - 4).Resize(, 4)
        Next c
    Next r
    End Sub

Posting Permissions

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