Enter year and supply 1st and last date

dbazzelle

New Member
Joined
Dec 4, 2003
Messages
38
Hello, I have this query:

Expr1: IIf(Year([dtmStartCovg])=[desired year],([mnySurchargePaid]/(DateDiff("d",[dtmStartCovg],[dtmEndCovg])+1))*RowMin((DateDiff("d",[dtmStartCovg],[dtmEndCovg])+1),(DateDiff("d",[dtmStartCovg],[desired end date]))+1),IIf(Year([dtmEndCovg])=Year([desired end date]),([mnySurchargePaid]/(DateDiff("d",[dtmStartCovg],[dtmEndCovg])+1))*(((DateDiff("d",[dtmStartCovg],[dtmEndCovg])+1-(DateDiff("d",[dtmStartCovg],[last day of prev year])+1))))))

and what I want to be able to do is replace the [desired end date] with 12/31/[desired year] and replace [last day of prev year] with 12/31/[desired year]-1 year. For example I would enter 2003 for [desired year] and would replace [desired end date] with 12/31/2003 and replace [last day of prev year] with 12/31/2002.

And if any one could sugest any way to clean this code up a bit :) Thank you for the time...

David
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Have a look at DatePart in the help files. That should give you what you want.

David
 
Upvote 0

Forum statistics

Threads
1,221,645
Messages
6,161,044
Members
451,682
Latest member
ogoreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top