Solved

How to set one column of an excel wrap text

Posted on 2011-03-06
7
870 Views
Last Modified: 2012-05-11
Piece of VB script to set one column of excel to have wrap text feature.
0
Comment
Question by:srikanthv2322
  • 4
  • 2
7 Comments
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 35051573
Hello,

what exactly do you mean? The cell alignment to "Wrap" text inside a cell or do you want a column to flow into another column once it reaches a certain row?

please post an example of before and after as an Excel file.

cheers, teylyn
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst earned 500 total points
ID: 35051632
This macro will set the cell formatting to wrap text in column A

Sub WrapColumnA()
    Columns("A:A").WrapText = True
End Sub

Open in new window


The keystrokes required to start the macro are about the same as using the Excel format dialog.

cheers, teylyn
0
 

Author Comment

by:srikanthv2322
ID: 35051653
I just want to wrap the text in all the cells in the given column, would need a piece of vb code to implement the same
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:longtruong
ID: 35051712
Hello srikanthv2322,

You can use following code to enable wrap text feature on any column specified by nCol variable:

Sub WrapText()

    Dim nCol As Long
    nCol = 2
    Range(Cells(1, nCol), ActiveCell.End(xlDown)).WrapText = True

End Sub

Open in new window


I hope it helps.

Long
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 35051713
Your post and my suggestion crossed over. Will that work for you?
0
 
LVL 3

Expert Comment

by:longtruong
ID: 35051873
Hello Teylyn,

When I was composing my post, I thought I was the first person who participated in this thread.  However, you were quicker than I was and thus, I am happy to withdraw from this thread :-).

Regards,

Long
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 35053013
Long, LOL, my post 35051713 also crossed with your comment. I meant the asker, not you. Feel free to stick around. No worries.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question