display column width and lenght

dgrosen

Board Regular
Joined
May 3, 2003
Messages
110
Hi everybody :o
Is there any formula or something to display on the first cell of each column the width of the column and on the first cell of each row the lenght of it?
:roll:
Thanks
Danny
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
dgrosen said:
Hi everybody :o
Is there any formula or something to display on the first cell of each column the width of the column and on the first cell of each row the lenght of it?
:roll:
Thanks
Danny

Not sure about a formula but you can get and write that info in VBA with

CW = ActiveCell.ColumnWidth
RH = ActiveCell.RowHeight
 
Upvote 0
Here are some user-defined functions that will do the trick:

Code:
Function Width(MyRange As Range) As Double
    Application.Volatile
    Width = MyRange.ColumnWidth
End Function

Function Height(MyRange As Range) As Double
    Application.Volatile
    Height = MyRange.RowHeight
End Function

You can then do =WIDTH(A2) or =HEIGHT(C1) etc.
 
Upvote 0
see help file for the cell() function, which has an argument for col width. oddly, it does not have a height equivalent ?!?
 
Upvote 0
Expanding on Paddy's good information, I have placed, in the first column cell of a given row, the formula =CELL("WIDTH",A1), where A refers to the first column whose width is desired. Then, I just copy that formula across the row, as far as I need, and, the column "widths" become visible.

However, be advised that you only get the rounded-up integer value of the width. Thus, if the width is 8.44, you obtain 8, and, if the width is 8.56, you obtain 9.

So, if you are needing to get exact values, the only way I know of is to put the mouse cursor at the meeting together of two consecutive column letters, say B and C, to read the width of column B. Then, write down the value read, and, so on.

Now, if you mean to format your columns so as to get a sheet that will fit on a given size paper sheet, the most practical way is to simply set your print area, then, you can see the dashed line that represents the edge of the paper. Now, you may proceed to reduce your columns as necessary to obtain the page width you need to print out.
 
Upvote 0
Here are some user-defined functions that will do the trick:

Code:
Function Width(MyRange As Range) As Double
    Application.Volatile
    Width = MyRange.ColumnWidth
End Function

Function Height(MyRange As Range) As Double
    Application.Volatile
    Height = MyRange.RowHeight
End Function

You can then do =WIDTH(A2) or =HEIGHT(C1) etc.

This user-defined functions worked great for me, but i need cell width and row height displayed in inches as in the page layout view mode. Is there any way to display those values in inches as excel do it?
 
Upvote 0
This code worked for me perfectly however does anyone know how to make the new "width" macro/udf become available from the default formula items? I work at a fairly large institution, and this could save a lot of time for others and remove risk of opening excel files with macros enabled if it could just be added to my our default install package. etc (sorry if the terms I am using are not quite right) -KJ
 
Upvote 0

Forum statistics

Threads
1,222,564
Messages
6,166,818
Members
452,074
Latest member
Alexinho

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top