Deducting the column width in number of characters from a spreadsheet

JohanXL

Board Regular
Joined
Jun 13, 2015
Messages
78
"On a worksheet, you can specify a column width of 0 (zero) to 255. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font. The default column width is 8.43 characters."

I have the following question:

If I have a spreadsheet with different column widths, is it possible in some way to display what those exact column widths are, i.e., to know exactly how many characters wide the different columns on my current spreadsheet are?

Thank you in advance for any tips.

JohanXL
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This macro will put the column widths in a specific row. Change the output row number 10 to suit.

Code:
[color=darkblue]Sub[/color] ColWidth()
    [color=darkblue]Dim[/color] col [color=darkblue]As[/color] Range
    [color=darkblue]For[/color] [color=darkblue]Each[/color] col [color=darkblue]In[/color] ActiveSheet.UsedRange.Columns
        Cells([COLOR=#ff0000]10[/COLOR], col.Column) = col.ColumnWidth         [color=green]'Change the 10 to the desired output row number[/color]
    [color=darkblue]Next[/color] col
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
This macro will put the column widths in a specific row. Change the output row number 10 to suit.

Code:
[COLOR=darkblue]Sub[/COLOR] ColWidth()
    [COLOR=darkblue]Dim[/COLOR] col [COLOR=darkblue]As[/COLOR] Range
    [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] col [COLOR=darkblue]In[/COLOR] ActiveSheet.UsedRange.Columns
        Cells([COLOR=#ff0000]10[/COLOR], col.Column) = col.ColumnWidth         [COLOR=green]'Change the 10 to the desired output row number[/COLOR]
    [COLOR=darkblue]Next[/COLOR] col
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

Thank you very much, AlphaFrog!
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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