I think you are asking two questions:Originally Posted by malik641
1. can a macro set "word wrap"?
2. can a macro adjust the width of the column to accomodate the text?
The answer to both is yes. For the first, you might try something like:
I use a centered vertical alignment whenever I wrap text (looks better to me), but you may not wish to do that.Sub WordWrap() Range("A2").Select With Selection .VerticalAlignment = xlCenter .WrapText = True End With End Sub
For the second, the width of the column will depend on the amount of text and the particular font & font size being used. If there is more than a dozen or so characters, you should use a combination of col width and word wrap. An example of setting col width based on text found in cell A2 might look like:
For the font and font size I was using (Arial 10), setting the width to # chars / 5 seemed like a good compromise.Sub ColWidth() Columns("A:A").ColumnWidth = Len(Range("A2").Text) / 5 End Sub
I assume you know how to convert your cascaded IF statement to VBA and how to combine the ideas above. Also, remember that setting the col width impacts every cell in that col.