473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Whats wrong with my code? Keep getting arguments not optional error

Below is the function I defined. It is supposed to calculate the amount of payment terms between two dates (rounded up) and do this according to a dropdown menu that gives users the option to select monthly, quarterly or yearly payments. Functions first argument is the result of this dropdown, the second argument is the first date and the third argument is the last date or end date for this specific payment plan.
The error message I'm getting is that the arguments aren't optional. The weird thing is that in excel im filling al the arguments (with cells in the form of
"Termijnberekening(C4;D4;F4)"

But it still gives me the error. Below my code:


Expand|Select|Wrap|Line Numbers
  1. Function Termijnberekening(Termijn As Variant, Ingangsdatum As Date, Einddatum As Date) As Integer
  2.     If Termijn = "Maand" Then
  3.         Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum)) * 12 + Month(Einddatum) - Month(Ingangsdatum)
  4.     ElseIf Termijn = "Kwartaal" Then
  5.         Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum)) * 4 + WorksheetFunction.RoundUp((Month(Einddatum) - Month(Ingangsdatum)) / 3)
  6.     ElseIf Termijn = "Jaar" Then
  7.         Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum))
  8.     Else
  9.         Termijnberekening = "Kies Termijn Type"
  10. End Function
May 31 '13 #1

✓ answered by Rabbit

Please use code tags when posting code.

Your thread has been moved to the Excel forum, you were in the wrong one.

The problem is line 5. The WorksheetFunction.RoundUp() function requires two arguments. The second argument is the number of digits to which you want to round the number.

2 1987
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

Your thread has been moved to the Excel forum, you were in the wrong one.

The problem is line 5. The WorksheetFunction.RoundUp() function requires two arguments. The second argument is the number of digits to which you want to round the number.
May 31 '13 #2
Ah thanks, Im a total novice to VBA and the debugger highlighted the first line which led me to think the error was in there.
May 31 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vernon | last post by:
Hi anyone, This is my code. int num num = 0; for(int a=0; a<count; ++a){ if(current->transID==aNo) ++num; current = current->next;
10
by: Chuck | last post by:
Hi! Any ideas as to how I can get ride of the script error undefined variable "Exp_Month"? I am trying to get this drop down list to default to the current month as opposed to 01. Thank...
5
by: Alexandre Martins | last post by:
Provider=Microsoft.Jet.OLEDB.4.0;UserId=Admin;Password=teste;Data Source=C:\Inetpub\wwwroot\inktoner\dados\db_inktoner.mdb;Persist Security Info=True I can't connect in my database ! whats...
6
by: Teep | last post by:
Below is my code for dropdownlist that is populated from a SQL table. After a selection from the ddl, a datagrid is suppose to come up pertaining to the information selected, but I keep getting a...
0
by: CAIBird | last post by:
hi, i've been developing a webservice on machine A and one WebMethod of this webservice will connect to SQL Server2000 on machine B using a connect string defined in Web.config as below: <add...
2
by: coolindienc | last post by:
Today I am going nuts. This is another one that is not working. It keeps giving me syntax error at highlighted line. No matter what I do I still have that error at the same line. It seems that my...
8
by: illuzion | last post by:
ok I keep getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/illuzion/public_html/BAMF/contactus.php on line 38 and this error is possibly on other lines could...
10
by: charmeda103 | last post by:
My program keeps getting me and error and i dont why here is the error message error C2061: syntax error: identifier 'infile' error C2660: 'ReadDate' : function does not take 6 arguments...
3
by: James Watson | last post by:
'Microsoft VB 6.3, Access 2002 'Syntax error in the INSERT INTO Statement when the query runs 'How can I make this work? Private Sub Command52_Click() On Error GoTo Err_Command52_Click ...
1
by: Wesley Blake | last post by:
#include <iostream> using namespace std; void main() { int centigrade; float calc_Fahrenheit; cout << " Type in a number for centrigrade: "; cin >> centrigrade; calc_Fahrenheit = 1.8 *...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.