Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2007, 01:48 AM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Merge cells and WrapText together

In My Application, i need to merge a few cells and at the same time use Wrap Text property to resize the cell for the content to fit exactly...
Can i get some help???
 
Old December 12th, 2007, 06:45 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

To do so with range A1:B12, try this:
------------------------
  With Range("A1:f2")
    .Rows.AutoFit
    .MergeCells = True
    .WrapText = True
  End With
------------------------

Remember that AutoFit only works as the spreadsheet setting does and too much content can confuse it. Another way to size it is to calculate the appropriate height yourself instead and use .height instead.

 
Old December 13th, 2007, 12:27 AM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the solution.
But my problem is,
the text is very large, so auto fit or wrap text is not working and to calculate the row height and assign it,the size of the text will be different for each sheet.
For each record in the table,i'm creating a sheet and displaying all the values and the content is not same in all the records, so i'm not able to assign the size manually to it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to merge cells in MS Flex Grid control manishdev Beginning VB 6 0 June 6th, 2007 09:03 AM
Merge Cells in Grid tiyyob .NET Framework 2.0 1 August 1st, 2006 04:42 AM
How to merge a set of cells? Jell Excel VBA 3 August 9th, 2005 01:15 AM
Merge and Split Cells in Matrix johnnychow.hike BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 October 25th, 2004 10:17 PM
Merge Cells in MshFlexgrid malavshah11 VB How-To 0 February 11th, 2004 07:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.