Excel Tutorial: Use VBA to instantly change row height based on value entered in worksheet cell

preview_player
Показать описание

// FREE Excel E-book "Record Your First Macro"

// Recommended Excel Courses //

// Recommended Excel Templates //

If you are looking for pre-built, easy to use spreadsheets, check out Simple Sheets.

They have Excel templates covering cash flow planning, invoices, expense reports, personal budgets, and more!

——
// EPISODE NOTES

In this tutorial video we look at how to automatically change row height by changing the value of a cell on your Excel worksheet using the built-in programming language VBA (Visual Basic for Applications).

We use a Worksheet_Change event to drive the automatic update.

I walk through two sample VBA Subroutines.

VBA Sub 1 - Automatically changes row height for ONE row.

VBA Sub 2 - Automatically changes row height for MANY rows.

——
// VIDEO TIMINGS

0:00 - Introduction
0:41 - Viewer Request Explained
2:00 - Worksheet Change Macro
4:15 - VBA Sub 1 Update_Row_Height
7:03 - How to Enter Worksheet Change Events (VBA Editor)
9:59 - Demo: Multiple Rows
10:51 - VBA Sub 2 Update_Row_Height_Range1
14:01 - Test Subroutines
15:40 - Outro

——
// DOWNLOAD WORKBOOK FOR THIS TUTORIAL

Please follow these instructions to learn from the workbook download:

▸ Open the workbook and make sure to enable macros

▸ Press ALT + F11 to open the VBA Editor

▸ Use F8 to step through the code one line at a time

▸ I suggest you adapt this to your own needs... just copy and paste the code, then change the code to work for you

▸ If you have a viewer request, leave me a comment below and I'll try to solve your problem in a new video

——
// REFERENCES

Excel Version: 2016 (used in video)

——
// VISIT MY WEBSITE

For more tutorials on Microsoft Excel and VBA visit the website
Рекомендации по теме
Комментарии
Автор

If you're totally new to Excel Macros & VBA... get my FREE e-book at this link:


Leave comments with any questions you have...

And click on the LIKE button if you found this video helpful.

Thanks for supporting my channel!

launchexcel
Автор

What about changing column width instantly base on value sir.. thanks

abdulcadersalem
Автор

Very nice! I used this but used other functions to get variable height of cells like (LEN) IF and Max to get the cell in a row that requires the most height. Thank you

edayers
Автор

How can use this code with worksheet calculate()?

elderbarboza
Автор

Hi, this video is very useful, unfortunately I am getting "Compile error, Expected list Separator or )"

amnahussain
Автор

Hi, I am new to Visual Basic and understand the basics of this tutorial however should i wish to determine the row height from a piece of text in a drop down list, for example one choice being "Basic" and the other being "Advanced" how do i assign the row height value of 0 to basic and 14.4 to Advanced.

stuartgalley
Автор

This is very helpful and was wondering if you could expandit a little further to have different row heights for a number of rows?

I have an application where I would need to control the row heights of 10-15 rows with varying heights.

Is this possible?

danstewart