View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default divide multiline text cell across several rows

Stuart

Many thanks. You understood.
Apologies I was not clear that a programmatical solution
was desired!


Well, you did post in .programming. I should have guessed.


However, following your suggestion I received this error:
"Text will extend beyond selected range" which could
potentially overwrite subsequent rows in the column?


You get that error message even if there's nothing to overwrite. You need
to set DisplayAlerts to False to avoid the message


However, I could first test for the rowheight of each cell,
divide by 12.75, then insert the required number of
additional rows.


That sounds like it would work. You could also just insert more than enough
rows, then delete what you don't need.

Sub test()

Application.DisplayAlerts = False

With ActiveSheet
.Range("2:10").Insert 'insert too many rows
.Range("B1").Justify 'justify the text
.Range(.Range("B10").End(xlUp).Offset(1, 0), "b10").Delete 'delete what
you don't need
End With

Application.DisplayAlerts = True

End Sub

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com