- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How To Display Row Height Or Column Width In Cells?
In order to efficiently organise and present data in Microsoft Excel, row heights and column widths are quite important. For a variety of reasons, such as altering formatting, aligning content, or examining data patterns, you may frequently need to know the precise dimensions of rows or columns. Although Excel offers default measures, it can be difficult to properly visualise these dimensions.
Fortunately, you can automate processes and increase your control over your worksheets thanks to Excel's robust programming language, Visual Basic for Applications (VBA). In this lesson, we'll look at how to display row heights or column widths within the actual cells using VBA code. Your productivity can be greatly increased by using this method, which also makes it simpler to use Excel's formatting tools.
Display Row Height Or Column Width In Cells
Here, we will first create a defined formula and use the formula to complete the task. So let us see a simple process to know how you can display row height or column width in cells in Excel.
Consider any Excel sheet. First, right−click on the sheet name and select View Code to open a VBA application. Then, click on "Insert" and select "Module.
Right click > View code > Insert > Module.
Then copy the below code into the textbox, similar to the below image.
Function RowHeight(MR As Range) As Double Application.Volatile RowHeight = MR.RowHeight End Function
Then click on an empty cell, enter the formula as =RowHeight(A1) and drag using the autofill handle.
Empty cell > Formula > Enter.
If you want to display the column width, use the below code and use the formula as =ColumnWidth(A1) then drag.
Function ColumnWidth(MR As Range) As Double Application.Volatile ColumnWidth = MR.ColumnWidth End Function
In this tutorial, we have used a simple example to demonstrate how you can display row height or column width in cells in Excel to highlight a particular set of data.
Kickstart Your Career
Get certified by completing the courseGet Started