Solved

How to set one column of an excel wrap text

Posted on 2011-03-06
7
863 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:teylyn
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:
teylyn 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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:teylyn
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:teylyn
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now