0

So I'm looking at a massive report at the moment and we get one in weekly and we want a macro to automate it. So one of the columns has numerous dates from 2012 to 2015 in it. I need to search for the 2014 dates and then from there put 2014 into the column directly on the right of it My code so far:

Sub Engagament_Hiring_Dates()
    Dim i As Long
    Dim k As Long
    For i = 2070 To 4000
        If Year(BDi) = "2014" Then
            Cells(i, 57) = "2014"
        End If
    Next i
End Sub
RubberDuck
  • 11,933
  • 4
  • 50
  • 95
Chris
  • 7
  • 5

1 Answers1

0

If your dates are in Column BD try this:

For i = 2070 To 4000
    If Year(Cells(i, "BD")) = 2014 Then
        Cells(i, 57) = "2014" 'or simply 2014
    End If
Next i

Year Function returns an Integer, so you need to compare it to a number and not a string.
This will work provided your values in Column BD are valid dates.

Also, you might want to check below on how to use Cells Property:

Using Cells

Community
  • 1
  • 1
L42
  • 19,427
  • 11
  • 44
  • 68