From the course: Excel: Macros in Depth (Microsoft 365)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Expanding a macro with the If statement
From the course: Excel: Macros in Depth (Microsoft 365)
Expanding a macro with the If statement
- We're looking at the workbook called Add If Code. In the previous movie, we recorded the macro to apply double accounting underlining. We want to expand and change that macro so that it's like a toggle switch. You're probably familiar with the bold and the italic and the underline buttons in Excel. They're on the Home tab, and they're what we call toggle switches. They're on/off. We can apply bold, later we might take it off. It's an on/off kind of switch. Let's do the same thing with the macro that was previously recorded. As we press Alt+F11 to go into VBA, in this worksheet we see that double accounting underlining macro that was used in the previous movie. Now, in order to allow us to turn off double accounting, we need to record a line that looks something like this except it removes underlining. And to make this simpler, what we're first going to do is to remove the other lines in this macro that are unrelated…
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.