Wrap text in column headers to fit text in column
Hello Rowan
Thank you for your reply Rowan, this comes close but I have now identified
another problem! Is there something that I can do so when the column headers
wrap to the autofit, the wrapping only occurs at breaks between words (not
anywhere within the word as I now have column headers that are difficult to
read where the width of the data in the column is only two or three
characters).
--
Thanks,
MarkN
"Rowan Drummond" wrote:
Maybe with a macro. Assuming your headers are in row 1:
Sub header()
Dim eCol As Integer
Dim i As Integer
Dim head As String
eCol = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To eCol
With Cells(1, i)
head = .Value
.ClearContents
.EntireColumn.AutoFit
.WrapText = True
.Value = head
End With
Next i
End Sub
Hope this helps
Rowan
MarkN wrote:
Hello,
I get about forty columns of data dumped into an Excel sheet every month.
The column headers at the top of the columns are usually considerably wider
than the data in the columns. I want to wrap the header text in each column
so that it is as wide as the widest entry in the rest of that column. Each
column width is diferent.
If anybody knows a quick method of doing this, it would save me a lot of time.
|