Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

End of Month Function in Visual Basic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fredriksson - 24 Jan 2007 20:21 GMT
I would like to initialize a text box in a user form with the last day of the
month calculated from the current date (Today)

I tried the following:

Private Sub UserForm_Initialize()
    Me.AcctPeriodInputBox.Value = EOMONTH(Date)
End Sub

How do I use Functions that are in Excel to calculate values in a macro?
merjet - 24 Jan 2007 20:34 GMT
Precede them by Application. or Application.WorksheetFunction.

Hth,
Merjet
Fredriksson - 25 Jan 2007 15:06 GMT
Thank you for your suggestion
>Precede them by Application. or Application.WorksheetFunction.
>
>Hth,
>Merjet
NickHK - 25 Jan 2007 02:56 GMT
If you are using VBA anyway, there's no need for external functions:

Public Function LastDayOfMonth(WhichMonth As Date) As Date
LastDayOfMonth = DateSerial(Year(WhichMonth), Month(WhichMonth) + 1, 0)
End Function

Adjust the argument/return value for your needs.

NickHK

> I would like to initialize a text box in a user form with the last day of the
> month calculated from the current date (Today)
[quoted text clipped - 6 lines]
>
> How do I use Functions that are in Excel to calculate values in a macro?
Fredriksson - 25 Jan 2007 15:06 GMT
Thank you for your suggestion

>If you are using VBA anyway, there's no need for external functions:
>
[quoted text clipped - 11 lines]
>>
>> How do I use Functions that are in Excel to calculate values in a macro?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.