Display all column width in Excel

ghans_12

New Member
Joined
Jan 21, 2010
Messages
28
Hi, I have lots of column in a excel sheet and I need to know the width of each of the column.
Is there any way, that all the width of columns will be displayed to me at one time rather than me going and checking them one-by-one.

Thanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Insert a row at the top of a copy of your sheet and run the following code:

Code:
Public Sub ColWidth()
Dim i As Long
For i = 1 To 256
   Cells(1, i).Value = Columns(i).ColumnWidth
Next i
End Sub
 
Upvote 0
Perhaps a macro to test the size of your data, then insert a row and enter the column width

Code:
Sub InsertColumnWidths()
Dim LstCol As Long
Dim my As Range
Dim c As Range
LstCol = Cells(1, Columns.Count).End(xlToLeft).Column
Range("1:1").Insert xlDown
Set my = Cells(1, 1).Resize(, LstCol)
For Each c In my
    c.Value = c.Width
Next c
End Sub
 
Upvote 0
Something like this perhaps? Every time you select a different cell, it will place the column width in every cell of row 1.

However, the numbers it returns are very different from right-clicking a column and viewing the width.:confused:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range

For Each cell In Range(Cells(1, 1), Cells(1, Columns.Count))
    cell.Value = cell.Width
Next cell
End Sub
 
Upvote 0
Try :-
Code:
[COLOR="Navy"]Sub[/COLOR] MG28Oct05
[COLOR="Navy"]Dim[/COLOR] Col [COLOR="Navy"]As[/COLOR] Range, Txt [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Col [COLOR="Navy"]In[/COLOR] ActiveSheet.UsedRange.Columns
    Txt = Txt & Col.Column & ";-  " & Col.Width & Chr(10)
[COLOR="Navy"]Next[/COLOR] Col
MsgBox "Col Num." & "Col Width" & Chr(10) & Txt
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try:
Code:
Sub ColumnWidth()
Dim i As Long
i = 1
Range("1:1").Insert shift:=xlDown
Do
    Cells(1, i).Value = Cells(2, i).Width
    i = i + 1
Loop Until IsEmpty(Cells(2, i))
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,406
Messages
6,171,927
Members
452,434
Latest member
NUC_N_FUTS2

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