Skip to content
Felix
  • Topics
    • My List
    • Felix Guide
    • Asset Management
    • Coding and Data Analysis
      • Data Analysis and Visualization
      • Financial Data Tools
      • Python
      • SQL
    • Credit
      • Credit Analysis
      • Restructuring
    • Financial Literacy Essentials
      • Financial Data Tools
      • Financial Math
      • Foundations of Accounting
    • Industry Specific
      • Banks
      • Chemicals
      • Consumer
      • ESG
      • Insurance
      • Oil and Gas
      • Pharmaceuticals
      • Project Finance
      • Real Estate
      • Renewable Energy
      • Technology
      • Telecoms
    • Introductory Courses
    • Investment Banking
      • Accounting
      • Financial Modeling
      • M&A and Divestitures
      • Private Debt
      • Private Equity
      • Valuation
      • Venture Capital
    • Markets
      • Economics
      • Equity Markets and Derivatives
      • Fixed Income and Derivatives
      • Introduction to Markets
      • Options and Structured Products
      • Other Capital Markets
      • Securities Services
    • Microsoft Office
      • Excel
      • PowerPoint
      • Word & Outlook
    • Professional Skills
      • Career Development
      • Expert Interviews
      • Interview Skills
    • Risk Management
    • Transaction Banking
    • Felix Live
  • Pathways
    • Investment Banking
    • Asset Management
    • Equity Research
    • Sales and Trading
    • Commercial Banking
    • Engineering
    • Operations
    • Private Equity
    • Credit Analysis
    • Restructuring
    • Venture Capital
    • CFA Institute
  • Certified Courses
  • Ask An Instructor
  • Support
  • Log in
  • Topics
    • My List
    • Felix Guide
    • Asset Management
    • Coding and Data Analysis
      • Data Analysis and Visualization
      • Financial Data Tools
      • Python
      • SQL
    • Credit
      • Credit Analysis
      • Restructuring
    • Financial Literacy Essentials
      • Financial Data Tools
      • Financial Math
      • Foundations of Accounting
    • Industry Specific
      • Banks
      • Chemicals
      • Consumer
      • ESG
      • Insurance
      • Oil and Gas
      • Pharmaceuticals
      • Project Finance
      • Real Estate
      • Renewable Energy
      • Technology
      • Telecoms
    • Introductory Courses
    • Investment Banking
      • Accounting
      • Financial Modeling
      • M&A and Divestitures
      • Private Debt
      • Private Equity
      • Valuation
      • Venture Capital
    • Markets
      • Economics
      • Equity Markets and Derivatives
      • Fixed Income and Derivatives
      • Introduction to Markets
      • Options and Structured Products
      • Other Capital Markets
      • Securities Services
    • Microsoft Office
      • Excel
      • PowerPoint
      • Word & Outlook
    • Professional Skills
      • Career Development
      • Expert Interviews
      • Interview Skills
    • Risk Management
    • Transaction Banking
    • Felix Live
  • Pathways
    • Investment Banking
    • Asset Management
    • Equity Research
    • Sales and Trading
    • Commercial Banking
    • Engineering
    • Operations
    • Private Equity
    • Credit Analysis
    • Restructuring
    • Venture Capital
    • CFA Institute
  • Certified Courses
Felix
  • Data
    • Company Analytics
    • My Filing Annotations
    • Market & Industry Data
    • United States
    • Relative Valuation
    • Discount Rate
    • Building Forecasts
    • Capital Structure Analysis
    • Europe
    • Relative Valuation
    • Discount Rate
    • Building Forecasts
    • Capital Structure Analysis
  • Models
  • Account
    • Edit my profile
    • My List
    • Restart Homepage Tour
    • Restart Company Analytics Tour
    • Restart Filings Tour
  • Log in
  • Ask An Instructor
    • Email Our Experts
    • Felix User Guide
    • Contact Support

User Defined Functions, Events and Arrays

An overview of user-defined functions in Excel VBA.

Unlock Your Certificate   
 
0% Complete

8 Lessons (40m)

Show lesson playlist
  • Description & Objectives

  • 1. Introduction to User Defined Functions

    01:30
  • 2. User Defined Functions Part 1 Workout

    03:53
  • 3. User Defined Functions Part 2 Workout

    12:37
  • 4. Workbook and Worksheet Events

    02:12
  • 5. Worksheet Events Workout

    04:07
  • 6. Workbook Events Workout

    03:44
  • 7. Arrays

    01:11
  • 8. Arrays Workout

    10:28

Prev: Variables and Looping Procedure Next: Modifying the User Interface

Arrays Workout

  • Notes
  • Questions
  • Transcript
  • 10:28

A workout to demonstrate how a two-dimensional array can be used to perform calculations.

Downloads

Arrays Workout EmptyArrays Workout Full

Glossary

Excel modeling
Back to top
Financial Edge Training

© Financial Edge Training 2025

Topics
Introduction to Finance Accounting Financial Modeling Valuation M&A and Divestitures Private Equity
Venture Capital Project Finance Credit Analysis Transaction Banking Restructuring Capital Markets
Asset Management Risk Management Economics Data Science and System
Request New Content
System Account User Guide Privacy Policy Terms & Conditions Log in
Transcript

We are required to write VBA code to declare a two-dimensional array Dimension.

One should be from 1 to 5 and dimension two should be from 1 to 3.

We then need to write four next looping procedure to assign the values in the range area.

Here we can see the range area to column one of the array in column two of the array, the values should be equal to the values from column one of the array multiplied by two, and the values in column three of the array should be equal to the values from column two of the array divided by 10, the value in cell B 15.

We finally need to sum column three of the array and assign this value to cell B 23.

Let's go into the visual basic editor and write our code.

We're going to write our code in a new module.

We insert module and we'll call our procedure workout 2.

The first thing that we need to do is to declare an array.

This will be a dimensional array with space for five elements in each column and three columns.

All of the data will be data type double.

We use DIM to declare the array and we'll call our array Test Array2.

The first dimension of the array should take elements from 1 to 5 and the second dimension of the array.

We're told to take elements from 1 to 3.

The data that will be held in that array will all be of type double.

This is the most flexible type as it can handle both whole numbers and decimals.

We now need a count variable that will be used to count through each of the items in the array and assign them with a value.

Let's call our count variable I and we can declare this as an integer type.

We now need to write our Four next code to fill each of those items within our array.

For I, our counter variable equals 1 to 5 each of the rows in the first dimension of our array, and we need to fill our first row of the array, the first row and the first column with the cells from the range area in the front end of Excel.

In order to do that, we identify our array called test array two and we identify a specific element within that array.

We identify the first row where I is equal to one and the first column.

This is the first element in our two dimensional array and we want that to be equal to the range area and specifically cells.

I where I equals one, one, and one.

We want the first element in our array to be equal to row one column one of that area, range of cells in the front end of Excel.

Let's deal with how we fill up the second column.

We identify that second column in our array named test array two row one, column two, and we want that to be equal to the value in test array.

Two row one column one, multiply by two as the instructions in our workout specified the final column of the array.

Well, we want that to equal the second column of the array, the value in that second column divided by 10, and we have the number 10 in cell B 15 in the front end of Excel test array.

Two, our newly created array.

Let's specify the elements within that array.

We want the first row and the third column, and we wish that to be equal to test array two First column Where I equals one first row rather where I equals one second column, but this time divided by range B 15.

The value property of B 15 is 10 and we can write looping procedure to go through each one of the rows in our array.

So when we move on to the next I, I will then be 2 and we fill all of row two in our array.

When I is 3, we fill row three and so on.

Let's adopt some good coding procedure and indent all of those instructions in the loop.

After all the elements of the array have been filled, the worksheet function index can be used to specify which elements we want to sum.

The first argument specifies the array.

The second is the first dimension here, zero as we wish to sum all of the rows in our array.

And the third argument, we specify the second dimension, and here we want to sum down column three of our array.

Let's write our function in range B 23.

We wish to sum all of the elements in our array and we need to use the worksheet function some.

To do that, we can use the worksheet function index to specify which cells in the array we wish to sum the array we identify as test array.

Two Second argument, we enter zero as we wish to rather some all of the rows in our chosen column.

And our chosen column is number three.

That is the third column from our second dimension of the array.

So worksheet function index is telling us to identify the test array two, all of the rows in that third column of the second dimension.

Let's close our brackets and return to the front end of Excel.

In the front end of Excel, we wish to execute our code.

We wish to execute our sub procedure named Workout2.

Now what we'll notice is that array does not have to be created in the front end of Excel.

These are all spaces in the memory of Excel VBA.

All of the calculations are being done in Excel VBA and we hope to get an output in the front end here in cell B 23.

Let's execute our code developer view macros and we're going to run workout2.

We get the figure of 700.

That figure of 700 of course is remember the sum of all of the elements in that third column, the column being the second dimension of our array.

That third column of the array is equal to the second column in our array, which is equal to the first column in our array multiplied by two.

And then we divide all of those numbers to get the third column figure.

We divide them by 10.

Let's test that this figure is correct. Let's divide.

Let's first multiply each of these elements by two and then divide by 10.

Copy all the way down, and if we sum each of these cells, we should get 700.

Content Requests and Questions

You are trying to access premium learning content.

Discover our full catalogue and purchase a course Access all courses with our premium plans or log in to your account
Help

You need an account to contact support.

Create a free account or log in to an existing one

Sorry, you don't have access to that yet!

You are trying to access premium learning content.

Discover our full catalogue and purchase a course Access all courses with our premium plans or log in to your account

You have reached the limit of annotations (10) under our premium subscription. Upgrade to unlock unlimited annotations.

Find out more about our premium plan

You are trying to access content that requires a free account. Sign up or login in seconds!

Create a free account or log in to an existing one

You are trying to access content that requires a premium plan.

Find out more about our premium plan or log in to your account

Only US listed companies are available under our Free and Boost plans. Upgrade to Pro to access over 7,000 global companies across the US, UK, Canada, France, Italy, Germany, Hong Kong and more.

Find out more about our premium plan or log in to your account

A pro account is required for the Excel Add In

Find out more about our premium plan

Congratulations on completing

This field is hidden when viewing the form
Name(Required)
This field is hidden when viewing the form
Rate this course out of 5, where 5 is excellent and 1 is terrible.
Were the stated learning objectives met?(Required)
Were the stated prerequisite requirements appropriate and sufficient?(Required)
Were the program materials, including the qualified assessment, relevant and did they contribute to the achievement of the learning objectives?(Required)
Was the time allotted to the learning activity appropriate?(Required)
Are you happy for us to use your feedback and details in future marketing?(Required)

Thank you for already submitting feedback for this course.

CPE

What is CPE?

CPE stands for Continuing Professional Education, by completing learning activities you earn CPE credits to retain your professional credentials. CPE is required for Certified Public Accountants (CPAs). Financial Edge Training is registered with the National Association of State Boards of Accountancy (NASBA) as a sponsor of continuing professional education on the National Registry of CPE Sponsors.

What are CPE credits?

For self study programs, 1 CPE credit is awarded for every 50 minutes of elearning content, this includes videos, workouts, tryouts, and exams.

CPE Exams

You must complete the CPE exam within 1 year of accessing a related playlist or course to earn CPE credits. To see how long you have left to complete a CPE exam, hover over the locked CPE credits button.

What if I'm not collecting CPE credits?

CPE exams do not count towards your FE certification. You do not need to complete the CPE exam if you are not collecting CPE credits, but you might find it useful for your own revision.


Further Help
  • Felix How to Guide walks you through the key functions and tools of the learning platform.
  • Playlists & Tryouts: Playlists are a collection of videos that teach you a specific skill and are tested with a tryout at the end. A tryout is a quiz that tests your knowledge and understanding of what you have just learned.
  • Exam: If you are collecting CPE points you must pass the relevant CPE exam within 1 year to receive credits.
  • Glossary: A glossary can be found below each video and provides definitions and explanations for terms and concepts. They are organized alphabetically to make it easy for you to find the term you need.
  • Search function: Use the Felix search function on the homepage to find content related to what you want to learn. Find related video content, lessons, and questions people have asked on the topic.
  • Closed Captions & Transcript: Closed captions and transcripts are available on videos. The video transcript can be found next to the closed captions in the video player. The transcript feature allows you to read the transcript of the video and search for key terms within the transcript.
  • Questions: If you have questions about the course content, you will find a section called Ask a Question underneath each video where you can submit questions to our expert instructor team.