Excel -- increase row height through cell entry (via VBA)
Posted on 2016-10-20
I am exploring to reorganize a spreadsheet. Before I do so, I am wondering if row height could be increased based on selection from a drop-down box (via VBA).
- Excel's default height of rows = 15.
- I have a spreadsheet that may have 30 rows.
- With row height set to 15, I could easily compare values of, e.g., cell A2 and cell A30.
- Given the values for some cells, the row height may increase to = 120 in order to show all cell content.
- If so, comparing row #2 with row #30 may be tedious and would required scrolling up/down constantly.
- Granted, I could freeze row #2 and then scroll up so that row #30 would appear right below row #2. However, I believe users may find that too cumbersome as they want to compare all types of data (e.g., compare row #3 with row n; then compare row #10 with row n, and so forth). Essentially, a user would have to constantly freeze/unfreeze rows to compare them. This is not ideal.
Here's what I envision:
- Use the default row height = 15.
- In row #1, have two drop-downs in cell A1 and B1.
- User selects/enters, e.g., "2" in A1 and "30" in B1. Based on selection of "2" and "30", I now want to increase the height of row #2 and row #30 and make them -- and only them -- equal to = 120 *or* set to "auto height" (via some form of macro/VBA).
- Upon analysis, user then wants to compare row 3 and row 10. Upon entering those two values in A1 and B1, rows #2 and #30 would shrink back to height = 15 while row #3 and #10 increase to height equal to 120 (or auto height).
Hopefully that makes sense. Looking forward to some VBA ideas that would automate the increase/decrease of row heights based on row value selections.