CALL

In this comprehensive guide, we will explore everything you need to know about the CALL function in Excel. The CALL function is a powerful and versatile formula that allows you to call a procedure in a dynamic-link library (DLL) or code resource. Although it is not commonly used in everyday Excel tasks, it can be incredibly useful for advanced users who need to integrate external functions into their spreadsheets.

CALL Syntax

The syntax for the CALL function is as follows:

=CALL(“Library”, “Procedure”, “TypeText”, Arg1, Arg2, …, ArgN)

Where:

  • Library is the name of the dynamic-link library (DLL) or code resource containing the procedure you want to call.
  • Procedure is the name of the procedure you want to call within the specified library.
  • TypeText is a string that specifies the data types of the procedure’s arguments and return value. Each character in the string represents a data type, and the order of the characters corresponds to the order of the arguments. The following characters can be used to represent data types:
  • A – Array
  • B – Byte
  • C – Currency
  • D – Double
  • F – Single
  • I – Integer
  • L – Long
  • R – Range
  • S – String
  • V – Variant
  • Arg1, Arg2, …, ArgN are the arguments that you want to pass to the procedure. The number of arguments must match the number of characters in the TypeText string.

CALL Examples

Let’s look at some examples of how to use the CALL function in Excel:

Example 1: Calling a simple DLL function

Suppose you have a DLL named “MyFunctions.dll” that contains a function called “AddTwoNumbers” which takes two integers as input and returns their sum. The TypeText for this function would be “III” (two integers for the input and one integer for the return value). To call this function in Excel, you would use the following formula:

=CALL(“MyFunctions.dll”, “AddTwoNumbers”, “III”, 5, 7)

This formula would return the sum of 5 and 7, which is 12.

Example 2: Calling a DLL function with a range

Imagine you have a DLL named “MyFunctions.dll” that contains a function called “SumRange” which takes a range of cells as input and returns the sum of the values in those cells. The TypeText for this function would be “RI” (one range for the input and one integer for the return value). To call this function in Excel, you would use the following formula:

=CALL(“MyFunctions.dll”, “SumRange”, “RI”, A1:A10)

This formula would return the sum of the values in the range A1:A10.

CALL Tips & Tricks

Here are some tips and tricks to help you get the most out of the CALL function in Excel:

  1. Make sure the DLL or code resource you are trying to call is properly registered on your system. If it is not registered, the CALL function will not be able to find the specified library and procedure.
  2. Ensure that the TypeText string accurately represents the data types of the procedure’s arguments and return value. If the data types do not match, the CALL function may produce unexpected results or cause Excel to crash.
  3. When working with DLLs, it is a good idea to familiarize yourself with the documentation for the library you are using. This will help you understand the available functions, their arguments, and their return values.
  4. Remember that the CALL function is not available in Excel Online or Excel for mobile devices. If you need to use a custom function in these environments, consider using a custom add-in or web service instead.

Common Mistakes When Using CALL

Here are some common mistakes that users make when using the CALL function in Excel:

  1. Using an incorrect or misspelled library or procedure name. Double-check the names of the DLL and procedure you are trying to call to ensure they are correct.
  2. Not providing the correct number of arguments or using the wrong data types in the TypeText string. Make sure your formula matches the expected input and output data types for the procedure you are calling.
  3. Attempting to use the CALL function in Excel Online or Excel for mobile devices. The CALL function is not supported in these environments.

Why Isn’t My CALL Function Working?

If your CALL function is not working as expected, consider the following troubleshooting steps:

  1. Verify that the DLL or code resource is properly registered on your system. If it is not registered, the CALL function will not be able to find the specified library and procedure.
  2. Check the names of the library and procedure you are trying to call. Make sure they are spelled correctly and match the names used in the DLL or code resource.
  3. Ensure that the TypeText string accurately represents the data types of the procedure’s arguments and return value. If the data types do not match, the CALL function may produce unexpected results or cause Excel to crash.
  4. Review the documentation for the library you are using to make sure you are calling the procedure correctly and providing the correct arguments.

CALL: Related Formulae

Here are some related formulae that you may find useful when working with the CALL function in Excel:

  1. RUN: The RUN function is another way to call a procedure in a DLL or code resource. It is similar to the CALL function but does not require a TypeText string. Instead, it automatically determines the data types of the arguments and return value based on the values you provide.
  2. REGISTER: The REGISTER function allows you to register a custom function in Excel. This can be useful if you want to create a more user-friendly interface for calling a procedure in a DLL or code resource.
  3. UNREGISTER: The UNREGISTER function allows you to unregister a custom function in Excel. This can be useful if you no longer need a custom function or want to replace it with a different version.
  4. GET.CELL: The GET.CELL function is an Excel 4.0 macro function that can be used to retrieve information about a cell or range. It can be useful for advanced users who need to access cell properties that are not available through standard Excel functions.
  5. EVALUATE: The EVALUATE function is an Excel 4.0 macro function that allows you to evaluate a text string as a formula. This can be useful for advanced users who need to perform calculations based on dynamic input or create custom functions that are not available in Excel.

With this comprehensive guide, you should now have a solid understanding of the CALL function in Excel and how to use it effectively. Remember to consult the documentation for the library you are using and ensure that your formulas accurately represent the data types of the procedure’s arguments and return value. Happy Excel-ing!

Related

Did you find this article useful?

Share it with your friends or colleagues

About Aepoch Advisors

We are a boutique accounting and consulting firm servicing international businesses operating in China. We offers book keeping and business advisory service. We also help our clients select and implement SAAS business applications
 
Cloud technology significantly reduces cost foreign companies traditionally spent on tax compliance and ERP systems. Our cloud professionals can help with streamlining your management and controling structure, as well as advising you on how to reduce risks and maximize profits with software purposely built for Chinese business. Contact us today to learn more about our services.