You will have to enter 01-05-2012, or you will have to enter 05-Jan-2012 Otherwise, everything works fine. By the way, what's with all days having 30 days? Jan has 31, Feb never has 30......
If you really are worried about the 30, use Private Sub CommandButton1_Click() Dim lngDays As Long, lngActualDays As Long On Error Resume Next lngDays = 30 lngActualDays = lngDays - Day(DateSerial(Year(TextBox2.Value), Month(TextBox2.Value), Day(TextBox2.Value))) + 1 TextBox3.Value = TextBox1.Value * lngActualDays / lngDays If Err.Number Then TextBox3.Text = "" End Sub Regards, Sam Mathai Chacko On Mon, Jan 23, 2012 at 7:14 PM, dguillett1 <dguille...@gmail.com> wrote: > Without looking too close, try /30 > > Don Guillett > SalesAid Software > dguille...@gmail.com > > From: Shankar Bheema > Sent: Monday, January 23, 2012 4:06 AM > To: excel-macros@googlegroups.com ; Sam Mathai Chacko > Subject: Re: $$Excel-Macros$$ Proportionate calculation > > Dear sir, > > I attached the excel file. An error is coming in calculation of the > proportionate pay. > > Here, assume that every month should have only 30 days irrespective their > actual days. > > suppose if a person is promoted on 05-01-2012, his pay would reflect as 30-4 > ==>26 days > > if pay is 1000/-, (1000/30)*26 days ==> result > > regards > shankar > On Mon, Jan 23, 2012 at 1:22 PM, Shankar Bheema <shankar.n...@gmail.com> > wrote: >> >> thank you sir >> >> >> On Sat, Jan 21, 2012 at 9:55 PM, Sam Mathai Chacko <samde...@gmail.com> >> wrote: >>> >>> Private Sub CommandButton1_Click() >>> >>> Dim lngDays As Long, lngActualDays As Long >>> On Error Resume Next >>> lngDays = Day(DateSerial(Year(TextBox2.Value), >>> Month(TextBox2.Value) + 1, 0)) >>> lngActualDays = lngDays - Day(DateSerial(Year(TextBox2.Value), >>> Month(TextBox2.Value), Day(TextBox2.Value))) + 1 >>> TextBox3.Value = TextBox1.Value * lngActualDays / lngDays >>> If Err.Number Then TextBox3.Text = "" >>> >>> End Sub >>> >>> On Sat, Jan 21, 2012 at 11:23 AM, Shankar Bheema <shankar.n...@gmail.com> >>> wrote: >>> > Dear Experts >>> > >>> > I am attaching an excel form, in which according to the promotion date >>> > text >>> > box the proportionate pay text box has to show in the command button >>> > event >>> > the pay of that particular month according to the days calculation. >>> > >>> > eg. if the pay is 1000/- pm (consider every calendar month should have >>> > 30 >>> > days only) >>> > suppose if the date of promotion is on 01-09-2011, the proportionate >>> > pay >>> > will remain 1000/- else if the date of promotion is on 02-09-2011 or >>> > 03-09-2011 so on... the remaining days of that particular month should >>> > be >>> > calculated and shown in that text box. >>> > >>> > Here if the Date of promotion is on 02-09-2011 >>> > remaining days will be 30-1 => 29 >>> > (1000/30) * 29 => 966.666666667 >>> > >>> > regards >>> > >>> > -- >>> > FORUM RULES (986+ members already BANNED for violation) >>> > >>> > 1) Use concise, accurate thread titles. Poor thread titles, like Please >>> > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >>> > will >>> > not get quick attention or may not be answered. >>> > >>> > 2) Don't post a question in the thread of another member. >>> > >>> > 3) Don't post questions regarding breaking or bypassing any security >>> > measure. >>> > >>> > 4) Acknowledge the responses you receive, good or bad. >>> > >>> > 5) Cross-promotion of, or links to, forums competitive to this forum in >>> > signatures are prohibited. >>> > >>> > NOTE : Don't ever post personal or confidential data in a workbook. >>> > Forum >>> > owners and members are not responsible for any loss. >>> > >>> > >>> > ------------------------------------------------------------------------------------------------------ >>> > To post to this group, send email to excel-macros@googlegroups.com >>> >>> >>> >>> -- >>> Sam Mathai Chacko >>> >>> -- >>> FORUM RULES (986+ members already BANNED for violation) >>> >>> 1) Use concise, accurate thread titles. Poor thread titles, like Please >>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will >>> not get quick attention or may not be answered. >>> >>> 2) Don't post a question in the thread of another member. >>> >>> 3) Don't post questions regarding breaking or bypassing any security >>> measure. >>> >>> 4) Acknowledge the responses you receive, good or bad. >>> >>> 5) Cross-promotion of, or links to, forums competitive to this forum in >>> signatures are prohibited. >>> >>> NOTE : Don't ever post personal or confidential data in a workbook. >>> Forum owners and members are not responsible for any loss. >>> >>> >>> ------------------------------------------------------------------------------------------------------ >>> To post to this group, send email to excel-macros@googlegroups.com >> >> > > > -- > FORUM RULES (986+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will > not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com > > -- > FORUM RULES (986+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will > not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com -- Sam Mathai Chacko -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com