In this post we will see how to get cell height and cell width value in a cell in excel.
We will use cell’s height and width properties in VBA to get the dimension of cell i.e. row and height.
Below is a cell and we are showing its height and width in terms of excel size in the cell
Step 1
Open VB editor from Develop the workbook in which we will write the code to get the dimension of the cell in terms of its weight and width
Step 2
Insert a module in which we will the VBA code.
Step 3
Now double click the newly created module to open that and paste the below code in the module.
Sub Get_Range()
Dim r As Range
Set r = ActiveSheet.Range(“A1”)
Range(“A1”).Value = “Width= ” & r.Width & ” ” & “Height= ” & r.Height
End Sub
This code will leverage width and height properties of range class and write the value of cell’s height and width in cell A1.
You can loop through this program to get height and width of all the cells in a range.
Hope this helped.