Skip to content

Instantly share code, notes, and snippets.

@alezhu
Created November 30, 2016 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alezhu/1a1540c992ecfa51c565015884ac497e to your computer and use it in GitHub Desktop.
Save alezhu/1a1540c992ecfa51c565015884ac497e to your computer and use it in GitHub Desktop.
Excel ColumnWidth for merged cells too
Function GetCellWidth(ra As range) As Double
Dim vColWidth As Double
Dim cell As range
vColWidth = ra.ColumnWidth
If ra.MergeCells Then
vColWidth = 0
For Each cell In ra.MergeArea.Cells
vColWidth = vColWidth + cell.ColumnWidth
Next
End If
GetCellWidth = vColWidth
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment