Review in an instant

VBA

Review in an instant

Cheat sheet for "VBA"

Table of contents

Introduction

1

Using Excel elements

2

- What is VBA?

- Writing in cells

- Copy/paste

- OFFSET

- Sheets

- Workbooks

Variables

6

- What are variables?

- How to use variables?

Bringing your code to life

7

- Loops

- If statements

- Combining Loops and If statements

Awesome tools

9

- Using normal functions in VBA

- Using Message Boxes

- Using Google to help you

- Speeding up code

Cheat sheet for "VBA"

Introduction

This cheat sheet gives you a quick summary of all the content in "VBA". Ever wanted to become a programmer and write code in Excel? This is your chance. VBA is the code language behind macros. You've already heard about macros, right? Writing VBA code directly in the VBA editor instead of recording it allows you to create some really effective macros. Macros that can do stuff you didn't even dream about. With VBA, you can write a macro that comes close to replicating a human Excel worker. What impact do you think this will have on your efficiency in Excel? That means learning to write VBA is one of the best career moves you can make! Use this sheet when faced with a specific challenge. Chances are, it will show you the steps on how to solve your situation. For example, if you forgot how to copy/paste stuff with VBA, you can just look it up. Or did you forget what variables are? We got you covered too. Protip: Search in the PDF for the word you're looking for. Let's say you want to know, if this cheat sheet covers how to do Loops. Search for the word "Loops" and BAM, there it is on page 7. Use this cheat sheet for when you want to review the content of this course. As time goes, you will forget a few things here and there. We all do! This cheat sheet gets you back up to speed in no time. Don't rush the lessons, take it at a nice, slow and steady pace. You'll soon surpass everyone else! One day, you'll also surpass your own wildest dreams of what you thought possible. If you at any point have any questions, feel free to reach out to me: kasper@ Cheers to your success!

Kasper Langmann Co-founder Certified Microsoft Office Specialist

1

Cheat sheet for "VBA"

Using Excel elements

What is VBA?

VBA stands for Visual Basic for Applications and is the code language behind macros. While macros itself is a tool for automation in Excel, the way you create a macro determines its usefulness. A recorded macro has a lot of limitations. If you can freely write VBA, you can create virtually anything in Excel. Then you become a true developer. Put very simple:

A macro automates stuff. VBA creates macros. Being good at VBA gives you really good macros.

Learning a whole new language might seem daunting, but it really consists of just a few key elements. When you master those, the rest comes as you go.

Writing in cells

To write in cells with VBA you set the value of the cell equal to the text or number you want in it.

Range("insert cell here").Value = "text"/number

If you want the value of cell B33 to be 56,449 use the above code in the following way: Range("B33").Value = 56449 If you want C10 to say "Hi there", use the above code in the following way: Range("C10").Value = "Hi there"

2

Cheat sheet for "VBA"

Copy/pasting with VBA

Copying To copy the content of cell(s) use the .Copy command.

Range("insert range here").Copy If you want the content of A1 through A100 use the above code in the following way: Range("A1:A100").Copy If you just want to copy a single cell use the above code in the following way: Range("C100").Copy Pasting To paste the content of copied cell(s) use the .PasteSpecial command.

Range("where you want to paste").PasteSpecial If you want the copied content to be pasted from cell C100 use the above code in the following way: Range("C100").PasteSpecial If you just want to paste the values without formatting or anything else use the above code in the following way instead: Range("C100").PasteSpecial xlPasteValues

3

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download