how to find total width of columns selected in exc

2019-08-04 10:54发布

I do not want to calculate the width using macro or so. I just want to select the columns in excel (just by clicking on each letter A,B,C and so on), then have a magic answer that the sum of width of each column I selected is some px. Excel only allows me to know width of each column only and if I change width of any column, it just makes all selected column that much wide.

Any hint is appreciated.

标签: excel
4条回答
一夜七次
2楼-- · 2019-08-04 11:01

This won't give you a magic answer, but it might make it quick to get an answer without any VBA.

1) Insert a blank row at the top of your document

2) In cell A1, enter the following formula:

=CELL("width", A1)

3) Apply the formula to all the other columns by dragging A1's slim-black-crosshair (it appears upon hover on the bottom-right corner of your cell).

What you'll get is a rounded Pixel value of each column's width. Then, simply select the the cells in row one for all the columns you want to add and look at the bottom of your Excel window. You should see the sum of your values as you make your selection. For example, if you want to sum the widths of columns A, B and D, select A1 CTRL+click B1 and CTRL+click D1. In the bottom right, you'll see their summed widths.

I hope this helps.

查看更多
SAY GOODBYE
3楼-- · 2019-08-04 11:19
Sub ColumnAuto4()

     '    Paul Pfau -- 8.02

     Dim Column_ As Integer
     Dim ColumnMin_ As Integer
     Dim Loop_ As Integer

     Cells.EntireColumn.AutoFit
     Column_ = 1

          For Loop_ = 1 To 20

          Cells(1, Column_).Select
          ActiveCell = "=CELL(""width"")"
          ColumnMin_ = ActiveCell.Value

               If ColumnMin_ < 4 Then
               ActiveCell.ColumnWidth = 4
               End If

          Column_ = Column_ + 1

          Next Loop_

End Sub
查看更多
看我几分像从前
4楼-- · 2019-08-04 11:21

Select the entire column and right click and you can see a option called Column width.

enter image description here

Click on Column width and you can see the width of a column in a new window.

enter image description here

查看更多
Viruses.
5楼-- · 2019-08-04 11:22

you can get to pick up column width by points through giving a cell a defined name. Refer to below, using cell A1 as example:

  1. Set cell A1 a defined name such as ColumnWidth
  2. In RefersTo, enter =get.cell(16,A1)
  3. In cell A1 or any other cell, make it equal to the defined name ColumnWidth, ie. =ColumnWidth
  4. Drag your formula across columns, the column width will display against each corresponding column

Note: Make sure in step 2 not to lock the cell name.

Hope this helps.

查看更多
登录 后发表回答