Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bill_De
 
Posts: n/a
Default Need help with custom function that deals with times

I made a tournament elimination chart in Excel that is totally automated.
Everything is working except for the custom function I am trying to create to
change the times for the start of each event.
Any help that anyone can give me with the correct way to write this function
would be greatly appreciated.

Here is the Function that I have created. The error code I get is: An END IF
statement mus have a corresponding IF statement.

All of the DIM statements are "As Variant"

Function Evtime(Time1, Time2)

Gameint = Index!M20
Lunchbk = Index!M21
Addtm = Index!M22
Pmstart = Index!M23
Gametm = AT5
Exp1 = (Time1 + Gametm + Gameint)
Exp2 = (Lunchbk - Gametm)
Exp3 = (Time2 + Gametm + Gameint)
Exp4 = (Time1 + Gametm + Gameint + Addtm)

If Exp1 < Exp2 Then Result1 = Exp1 Else Result1 = Pmstart
If Exp1 Exp2 Then Result1 = Exp1 Else Result1 = Pmstart

If Exp1 = Exp3 Then Evtime = Result1 Else Evtime = Exp4

End IF
End Function
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Kevin Vaughn
 
Posts: n/a
Default Need help with custom function that deals with times

You have an End If with no corresponding If statement. All of your If
statements are completely on one line. So, get rid of the End If statement.
Also, it looks like there is the possibility that Evtime may never get a
value, for instance if exp1 < exp2. You may want to do all of your tests
first, and return the values to Result1 and then make Evtime = result1.
--
Kevin Vaughn


"Bill_De" wrote:

I made a tournament elimination chart in Excel that is totally automated.
Everything is working except for the custom function I am trying to create to
change the times for the start of each event.
Any help that anyone can give me with the correct way to write this function
would be greatly appreciated.

Here is the Function that I have created. The error code I get is: An END IF
statement mus have a corresponding IF statement.

All of the DIM statements are "As Variant"

Function Evtime(Time1, Time2)

Gameint = Index!M20
Lunchbk = Index!M21
Addtm = Index!M22
Pmstart = Index!M23
Gametm = AT5
Exp1 = (Time1 + Gametm + Gameint)
Exp2 = (Lunchbk - Gametm)
Exp3 = (Time2 + Gametm + Gameint)
Exp4 = (Time1 + Gametm + Gameint + Addtm)

If Exp1 < Exp2 Then Result1 = Exp1 Else Result1 = Pmstart
If Exp1 Exp2 Then Result1 = Exp1 Else Result1 = Pmstart

If Exp1 = Exp3 Then Evtime = Result1 Else Evtime = Exp4

End IF
End Function

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John Michl
 
Posts: n/a
Default Need help with custom function that deals with times

If statements in VBA are different than in a worksheet. You need to
put and End If after each of the IF statements instead of just after
the last one. See if that helps. I didn't check the rest of the code
but that should be a start.

- John

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
Custom Function SPeterson Excel Discussion (Misc queries) 3 December 21st 05 07:12 PM
UDF help please Adam Kroger Excel Discussion (Misc queries) 3 December 17th 05 07:21 PM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
Whats the function to count the total times a word is displayed Monk Excel Discussion (Misc queries) 3 December 10th 04 10:39 PM
How can use IF function more than 7 times in a cell wuwu Excel Worksheet Functions 4 November 13th 04 10:23 AM


All times are GMT +1. The time now is 10:17 PM.

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"