Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Excel Investment Banking VBA Slides

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Excel for Investment

Banking and Your First VBA


Macro
How to Get Results Without Reading 500
Pages of VBA Books First
Our Top Questions About VBA and Macros…
“Do I really need to know VBA and
Macros? How useful are they? What
about R, Python, and other programming
languages?”

“How much time should I spend learning


these before my internship or full-time
job begins?”
Short Answers to These Questions:
• Yes, it helps to be familiar with VBA and macros – but you don’t
need to be an expert or have super-advanced knowledge

• You won’t be tested on them in IB interviews, but they can make


your on-the-job life easier

• Other languages, such as R and Python, are not useful for the
roles we focus on (IB, PE, CD, ER) – they’re more for trading,
portfolio management, or jobs with heavier statistical analysis

• Time to Spend: If you spend ~2 months learning/practicing Excel,


maybe take 1 week to learn some VBA; it’s “icing on the cake”
How to Learn VBA Syntax
• Best Method: Start by recording macros (sequences of actions) in
Excel, and then review and modify the code

• Most Excel constructs also carry over to VBA – IF statements,


functions like INDEX and MATCH, ranges of cells, formatting, etc.

• The difference is that you can do more with these constructs, such
as “looping” through a specific range, or “saving” data for use in
some other function or directly on the spreadsheet

• Think of VBA as a way to automate your work and save time;


don’t think of it as “learning a new language” (intimidating)
Your First VBA Macro
• Here: You’ll start by recording your first macro to create an
“Input Box” in Excel – very simple, and it shows the basic steps

• Why: Creating an input box doesn’t require tons of logic or error


checking, but it’s annoying and repetitive without a macro

• Why: It requires you to change the borders, fill color, and font
color, and there’s no way to do all of that at once in a single key
stroke (and it’s even more annoying in Mac Excel)

• And: We can’t just use Copy and Paste Special → Formats because
we do not want to copy the Number Formats!
Your First VBA Macro
• How: We can create a macro for this by recording completion of
these actions in Excel, and then tweaking the code a bit

• Basic Macro: It works, but there are some issues…

• Issue #1: Way too much code → don’t need separate “With”
statements for the borders, interior, etc. (group them together)

• Issue #2: It’s not very readable because there are too many
useless commands, and it’s hard to tell what the colors are

• Issue #3: We should skip empty cells to make it more efficient


Your First VBA Macro
• Most Issues: Can be fixed with simple reorganization of the code
and RGB values for the colors

• More Complicated: Skipping empty cells and formatting Input


Boxes with constants vs. formulas differently (blue vs. black)

• Solution: We can “intersect” the user’s selected range (single cell


or multiple cells), with the “Used Range” of the spreadsheet and
the Formulas or Constants in the selected range

• Then: Set the font colors for these Formulas or Constants first, and
then do the border/fill/font/alignment formatting if cells exist
Recap and Summary
• Is VBA Useful? Yes, but you don’t need to be an expert

• Best Methods to Learn: Record macros, then go to the VBA Editor


and review and edit the code

• Our Approach: Simple, highly useful macros focused on


automating repetitive tasks in Excel, with some tweaking

• First Macro: “Input Box” creation in any financial model or


valuation spreadsheet

• More: Skip empty cells, format formulas vs. constants, etc.

You might also like