title: How do I use VBA DateAdd on selected cells only
body: <p>Hope someone can help please, I am using the below code to add a year to dates in column A, whilst this works perfectly as is, I would like to only apply this change to the date based on the contents of column B. eg if cell B4 has Yes then add 1 year to the date in A4 etc, just cant seem to work the logic through to check the contents of B to change A within this loop. thanks. Kevin</p>
  <pre><code>Sub DateChange()
  Dim r As Range
  With Range(&quot;a1&quot;, Range(&quot;a&quot; &amp; Rows.Count).End(xlUp))
   For Each r In .Cells
   If IsDate(r.Value) Then
   r.Value = DateAdd(&quot;yyyy&quot;, 1, r.Value)
   End If
   Next
  End With
  End Sub
  </code></pre>