From the course: Office Scripts In Excel: Automating Tasks

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Solution: AutoFit and freeze panes for all workbooks

Solution: AutoFit and freeze panes for all workbooks - Microsoft Excel Tutorial

From the course: Office Scripts In Excel: Automating Tasks

Solution: AutoFit and freeze panes for all workbooks

Welcome back. I hope you enjoy tackling this challenge. Let's dive into the solution. First, let's head into the Financial Budget Planning workbook to autofit the columns and freeze panes using Record Actions. When I am done recording my steps, I will click Stop. Let's give the script a name, something like Autofit and Freeze Panes, enter, and let's revisit this script. So if I hit Edit Code, the modification we need to make is to add a second variable. Let's call it numRows. This will be a number data type. Next, we'll head down to the last line in our script where the value, 1, is currently hard coded. I'm going to replace that with the numRows variable, allowing us to dynamically set the number of rows to freeze. Let's save the script and run it to test. We can set our number of rows to another number like two. And if I run the script, you will see that now it is frozen to the second row. Great work. You can find this script in the exercise files under autofit-freeze-panes.txt…

Contents