From the course: Excel: Learning VBA
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Streamline code references using With…End With statements - Microsoft Excel Tutorial
From the course: Excel: Learning VBA
Streamline code references using With…End With statements
- [Instructor] Writing effective Excel VBA macros requires two related but distinct skills. The first skill is the knowledge of the Excel object model, and the second is efficiency. You need to be able to write code that runs quickly but that also can be written and read quickly. One way to increase your programming efficiency is to use with and blocks within your code. Rather than create an example by hand, I'll show you what happens when I record a macro that has me changing two aspects of the value in cell A1. To demonstrate, I will use the O2_08_With sample file and you can find that in the Chapter Two folder of the "Exercise Files" collection. This workbook contains a single worksheet. My goal is to create a macro, that is, record a macro that will change the formatting of the text in cell A1 so that it is in the Cambria font and 18 point in size. I'll start by clicking away so that we'll select cell A1 when we come back to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Introduce Excel VBA data types4m 5s
-
(Locked)
Declare variables and require declaration before use5m 27s
-
(Locked)
Manage variable scope3m 50s
-
(Locked)
Define static variables and constants5m 42s
-
Create a calculation using mathematical operators5m 10s
-
(Locked)
Define arrays7m 10s
-
Define and use object variables3m 3s
-
(Locked)
Streamline code references using With…End With statements4m 40s
-
(Locked)
Challenge: Define variables, constants, and calculations2m 5s
-
(Locked)
Solution: Define variables, constants, and calculations3m 13s
-
(Locked)
-
-
-
-
-
-