excelvbacolumn-width

Excel VBA - Calculate column width in inches


I am trying to determine the width of a column in inches. This formula sets the width to 5 inches but I cannot see how wide in inches column C is...

Columns("D:D").ColumnWidth = Application.InchesToPoints(5) * (Columns("D:D").ColumnWidth / Columns("D:D").Width)

Solution

  • Divide the column width by Application.InchesToPoints(1) (which is basically 72).

    MsgBox Columns("C").Width / Application.InchesToPoints(1)
    

    "Columnwidth" isn't in point, "Width" is in points.