Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default End of Month Function in Visual Basic

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?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default End of Month Function in Visual Basic

Precede them by Application. or Application.WorksheetFunction.

Hth,
Merjet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default End of Month Function in Visual Basic

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

"Fredriksson via OfficeKB.com" <u27002@uwe wrote in message
news:6cc6f82b6e6b0@uwe...
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?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default End of Month Function in Visual Basic

Thank you for your suggestion
merjet wrote:
Precede them by Application. or Application.WorksheetFunction.

Hth,
Merjet


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default End of Month Function in Visual Basic

Thank you for your suggestion

NickHK wrote:
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?


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How should I do this (function or Visual basic) Pasi[_2_] Excel Worksheet Functions 5 November 24th 08 07:42 PM
Call a Visual Basic Function with VLookup ajd Excel Worksheet Functions 10 December 18th 07 03:40 AM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
Call XLA function in Visual Basic Macro ? Thibaud Bouquely Excel Programming 5 March 2nd 05 08:37 PM
How do I use an array function in Visual basic .NET? cirrus Excel Programming 1 October 22nd 04 04:23 PM


All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"