LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling a function from Select case


Hello. On a form which adds a record to the active sheet, I am trying
to call a choice of 3 functions from their modules, using Select Case
where whatever the result of the function gets placed into the relevant
cell on the active sheet. I can't get it to work and was wondering if
someone could show me what is missing from it. I am getting error 449
(argument not optional) on the line ': Application.run' etc. Here is
the relevant part of my coding:

Select Case ActiveSheet.Name
Case "Sheet 1", _
"Sheet 2", _
"Sheet 3" _
: Application.Run "StartofMonth5yrs"
Cells(Nextrow, 3) = StartOfMonth5yrs(Date)

Case "Sheet 4", _
"Sheet 5", _
"Sheet 6" _
: Application.Run "StartofMonth6yrs"
Cells(Nextrow, 3) = StartOfMonth6yrs(Date)

Case "Sheet 7", _
"Sheet 8" _
: Application.Run "StartOfMonth2yrs"
Cells(Nextrow, 3) = StartOfMonth2yrs(Date)
End Select

'Here is one of the 3 function codes which takes today's date, and
calculates to the first day of the following month adding either 5, 6
or 2 years depending on the Select Case choice:

Function StartOfMonth5yrs(InputDate)
If IsDate(InputDate) Then
StartOfMonth5yrs = DateSerial(Year(InputDate) + 5,
Month(InputDate) + 1, 1)
Else
StartOfMonth5yrs = Empty
End If
End Function

Thank you.


--
Blondegirl
------------------------------------------------------------------------
Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615
View this thread: http://www.excelforum.com/showthread...hreadid=539683

 
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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Create Select Case Function Catalin[_2_] Excel Programming 6 March 27th 06 10:45 AM
Calling Macro when using Select Case helmekki[_49_] Excel Programming 1 October 30th 04 12:22 AM
Excel Custom Function with Select Case Heather[_7_] Excel Programming 14 November 6th 03 11:37 PM


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

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

About Us

"It's about Microsoft Excel"