View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ExcelMonkey[_81_] ExcelMonkey[_81_] is offline
external usenet poster
 
Posts: 1
Default Repost:I accidentally posted this in the general excel forum. Date Logic

I accidentally posted this in the general excel forum,,sorry


I have a date formula that I need to rewrite in VBA. Essentially i
takes a date expressed in the format:m/d/yyyy h:mm, and then adds hour
to it incrementally down rows. The first date is a constant, the secon
date is the addition of one hour but the third date onward is a bi
formula. Effectively the formula keeps adding hours but takes int
account daylight savings in the months of april and october.

I am not sure how to recreate this in VBA due to the brackets used i
excel

In excel it looks like this:

A1 = 1/1/2002 0:00
B2 = a1+1/24
C2 =A2+1/ 24+IF(AND(MONTH(A2)=4,WEEKDAY(A2)=1,HOUR(A2)=1,EOM
ONTH(A2,0)-A222),1
24,0)+IF(AND(MONTH(A2)=10,WEEKDAY(A2)=1,HOUR(A2)=1
,HOUR(A1)=0,EOMONTH(A2,0)-A2<7),-1/24,0)

In vba it looks like this:

date1 = a1 = 1/1/2002 0:00
date2 = Serial(date1) + 1/24 'Is this correct?
date3 = ?????????????? 'Recreate big formula

Does anyone know how to do this

--
Message posted from http://www.ExcelForum.com