98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Function using IF AND
Function using IF AND
Resolved · High Priority · Version 2003
David has attended:
Excel VBA Intro Intermediate course
Function using IF AND
Hello Simon,
I attended training 17/18 June, I asked your about creating a function using IF AND statements or an alternative to workout if dates fall within a month and you said to submit the question to the forum so here it is.
I have a spreadsheet for payments and in each month someone can be on Full Pay or Half Pay.
So if Half pay started on 15th June the function would look to see if 15th June was between 1 amd 30th
I need to create a function that can work this out as using functions in the front of excel I am limited to 7 If statements.
Thank You
RE: Function using IF AND
Hi David
Thanks for your question
This is difficult to answer precisely without seeing the spreadsheet. However the key is probably the datepart function which can be used to check the day element of a date.
So
Dim dteDate As Date
dteDate = #2/10/2010#
If DatePart("d", dteDate) > 1 Then
If DatePart("d", dteDate) < 9 Then
MsgBox "do Stuff"
Exit Sub
End If
End If
MsgBox "don't do stuff"
The above checks to see if the day element of a date is between 1 and 9. If so it does one thing, otherwise it does something else.
Hope this helps
Regards
Stephen
RE: Function using IF AND
Hi Stephen
Thanks for coming back to me, although slightly confused with this.
Not sure why checking the day element of a date will help.
Regards
David
RE: Function using IF AND
Hi david
Sorry, perhaps I have misunderstood your needs.
I thought that you wanted to check whether a date fell between 2 dates in a particular month. So you might want to see if the 15th of june fell between say the first and the 19th of that month.
If this is not the case could you please clarify?
Thanks
Stephen
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Printing spreadsheets without opening them firstHere's a fast way of printing a spreadsheet from Windows Explorer/My Computer. |