如何计算总列宽

复制这段代码,在excel中按Alt+F11打开VBA编辑器,双击This Workbook,在右边的窗口中粘贴代码,关闭。 选中列后,点开发工具—宏,执行。 记得要选中,你想相加的行

  1. Sub width()
  2. Dim N#, Col As Range
  3. N = 0
  4. For Each Col In Selection.Columns
  5. N = N + Col.ColumnWidth
  6. Next Col
  7. MsgBox N
  8. End Sub

如何计算总行高

  1. Sub height()
  2. Dim N#, Col As Range
  3. N = 0
  4. For Each Col In Selection.Rows("1:11") #第1行到第11行
  5. N = N + Col.RowHeight
  6. Next Col
  7. MsgBox N
  8. End Sub

1磅≈0.353mm