Computing.Net > Forums > Programming > Excel VBA function

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel VBA function

Reply to Message Icon

Name: RJW13
Date: January 22, 2009 at 00:46:46 Pacific
OS: Windows XP Home Edition
CPU/Ram: 512MB
Product: Dell / Inspiron 8600
Subcategory: General
Comment:

Hi,

I'm trying to create a function that allows me to put in two different months (either as text or numbers it doesn't matter) and then tell me the date that a payment is due.

Basically, provisional tax is due three times a year and depending on when a person's balance date is the three dates change.

I have a very basic knowledge of VBA and am a little rusty. I can't seem to make the function work.

Here is what I have so far:
Function ProvTax(BalanceDate, Month)
If BalanceDate = "October" Then
If Month = "December" Or "January" Or "February" Or "March" Then
ProvTax = "28 March"
ElseIf Month = "April" Or "May" Or "June" Or "July" Then
ProvTax = "28 July"
ElseIf Month = "August" Or "September" Or "October" Or "November" Then
ProvTax = "28 November"
End If


ElseIf BalanceDate = "November" Then
If Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "7 May"
ElseIf Month = "June" Or "July" Or "August" Then
ProvTax = "28 August"
ElseIf Month = "September" Or "October" Or "November" Or "December" Or "January" Then
ProvTax = "15 January"
End If

ElseIf BalanceDate = "December" Then
If Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "28 May"
ElseIf Month = "June" Or "July" Or "August" Or "September" Then
ProvTax = "28 September"
ElseIf Month = "October" Or "November" Or "December" Or "January" Then
ProvTax = "28 January"
End If

ElseIf BalanceDate = "January" Then
If Month = "March" Or "April" Or "May" Or "June" Then
ProvTax = "28 June"
ElseIf Month = "July" Or "August" Or "September" Or "October" Then
ProvTax = "28 October"
ElseIf Month = "November" Or "December" Or "January" Or "February" Then
ProvTax = "28 February"
End If

ElseIf BalanceDate = "February" Then
If Month = "April" Or "May" Or "June" Or "July" Then
ProvTax = "28 July"
ElseIf Month = "August" Or "September" Or "October" Or "November" Then
ProvTax = "28 November"
ElseIf Month = "December" Or "January" Or "February" Or "March" Then
ProvTax = "28 March"
End If

ElseIf BalanceDate = "March" Then
If Month = "June" Or "July" Or "August" Then
ProvTax = "28 August"
ElseIf Month = "September" Or "October" Or "November" Or "December" Or "January" Then
ProvTax = "15 January"
ElseIf Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "7 May"
End If

ElseIf BalanceDate = "April" Then
If Month = "June" Or "July" Or "August" Or "September" Then
ProvTax = "28 September"
ElseIf Month = "October" Or "November" Or "December" Or "January" Then
ProvTax = "28 January"
ElseIf Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "28 May"
End If

ElseIf BalanceDate = "May" Then
If Month = "July" Or "August" Or "September" Or "October" Then
ProvTax = "28 October"
ElseIf Month = "November" Or "December" Or "January" Or "February" Then
ProvTax = "28 February"
ElseIf Month = "March" Or "April" Or "May" Or "June" Then
ProvTax = "28 June"
End If

ElseIf BalanceDate = "June" Then
If Month = "August" Or "September" Or "October" Or "November" Then
ProvTax = "28 November"
ElseIf Month = "December" Or "January" Or "February" Or "March" Then
ProvTax = "28 March"
ElseIf Month = "April" Or "May" Or "June" Or "July" Then
ProvTax = "28 July"
End If

ElseIf BalanceDate = "July" Then
If Month = "September" Or "October" Or "November" Or "December" Or "January" Then
ProvTax = "15 January"
ElseIf Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "7 May"
ElseIf Month = "June" Or "July" Or "August" Then
ProvTax = "28 August"
End If

ElseIf BalanceDate = "August" Then
If Month = "October" Or "November" Or "December" Or "January" Then
ProvTax = "28 January"
ElseIf Month = "February" Or "March" Or "April" Or "May" Then
ProvTax = "28 May"
ElseIf Month = "June" Or "July" Or "August" Or "September" Then
ProvTax = "28 September"
End If

ElseIf BalanceDate = "September" Then
If Month = "November" Or "December" Or "January" Or "February" Then
ProvTax = "28 January"
ElseIf Month = "March" Or "April" Or "May" Or "June" Then
ProvTax = "28 May"
ElseIf Month = "July" Or "August" Or "September" Or "October" Then
ProvTax = "28 September"
End If

End If

End Function

It is probably hopelessly wrong, but can anyone tell me if I am on the right track?

I was thinking about changing all the text to numbers, ie just make the month names the number they relate to (Jan =1)

Thanks in advance.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Excel VBA function

Excel VBA Problem saving file www.computing.net/answers/programming/excel-vba-problem-saving-file-/14722.html

excel vba macro assistance www.computing.net/answers/programming/excel-vba-macro-assistance/10837.html

VBA math function for time dilation www.computing.net/answers/programming/vba-math-function-for-time-dilation/6177.html