Hi Muneer In essence this is almoost impossible.
The width of each letter varies so if you type iiiiiiii and mmmmmmmm they each contain the same number of characters but the width of each is very different. The only way I know of to work out how much of a particular string will fit in a given cell width is by accessing the font table which is part of each font. As far as I know there is no way to access this from within excel so you are down to writing a program in C to do it. In theory you could start with a string which overfilled the cell, having set the cell to wordwrap and autoheight. you could test its height until it held only one line of text.while you deleted characters one at a time from the end of the string. It would be a slow process as you would need to redisplay the screen after each letter was chopped off. Then you could put the balance of the string in the next cell down ad start again on that cell. This could not be reasonably done as you typed. It would have to be done, at the earlies, when you pressed enter to complete the cell.Then you would be locked out of the spreadsheet for a time until the program had done its thing. It would probably be better to do all the typing just not minding that you were overfilling the cells and then have a button to run the macro to do the line breaks. By the way this method would not work on merged cells. If you subsequently wanted to change what had been entered this would cause a lot of problems. I have no idea what you mean in your first condition. What do you mean by a "train" Is this the first condition or is it a test to be carried out after the text has been split into separate cells? What do you want to happen if the "train" would otherwise cross the page break? Do you want to delete any excess text? Do you want to go to the top of the next column on that page? Blow a whistle to alert the user? Move to the next sheet? increase the column width and try again? (incidentally determining where page breaks will occur is very difficult in Excel unless you predetermine that there will be a set number of rows/columns on each page.) As you can see there are a lot of problems in this exercise which is probably why you have had little response as yet. I do not have the skills to do this using the font tables method and do not want to spend the time doing it in excel as I suspect it would be unsatisfactory anyhow. Word might be a better program to use for your purpose. Perhaps putting your data into a table. Woird is much better at wrapping text than Excel is. Regards David Grugeon -- Join official facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES (1120+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. 6) Jobs posting is not allowed. 7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To post to this group, send email to excel-macros@googlegroups.com. To unsubscribe from this group, send email to excel-macros+unsubscr...@googlegroups.com.