View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
TraversE TraversE is offline
external usenet poster
 
Posts: 1
Default Is there a way to change all dates in a spread sheet

Try

Sub NextYear()
intRows = ActiveSheet.UsedRange.Rows.Count
For i = 1 To intRows
oldDate = ActiveSheet.Cells(i, 1).Value
If IsDate(oldDate) Then
newDate = DateAdd("yyyy", 1, oldDate)
ActiveSheet.Cells(i, 1).Value = newDate
End If
Next
End Sub

* will not account for leap years.
--
Eric Travers


"delete automatically" wrote:

I have a spread sheet with dates for the whole year of 2006. Exmaple I have
1/1/06 thru 1/15/06 in the first 14 rows. Then rows 15 thru 20 have other
data. Then start with 1/16/06 thru 1/29/06 then more data. How can I changed
the dates to the right dates of 2007 without gong to each block of dates.