Hanging indent - VBA solution Excel?

MikeL

Active Member
Joined
Mar 17, 2002
Messages
488
Office Version
  1. 365
Platform
  1. Windows
Hi ,
I have Wrap Text enabled thru VBA. How do I indent the second line by two spaces in VBA? I set to True but doesn't seem to work.

With Selection
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = True
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
There are at least two ways to do it:

.IndentLevel = 2

or

.InsertIndent 2

I don't know what is the difference because to me they both seem to do exactly the same thing.
 
Upvote 0
Thanks for the response.

Here is my problem. I want to do what is called a hanging indent. Meaning that the indention only starts at the second and subsequent lines after the wrap text. It appears that .IndentLevel and InsertIndent are applying to all lines in the cell. See attached results after using the suggested code. How can indent only be applied to second and subsequent lines?

 

Attachments

  • MrExcel_UnexpectedResult for indentation.PNG
    MrExcel_UnexpectedResult for indentation.PNG
    4.7 KB · Views: 7
Upvote 0
As far as I know it cant, the indent applies to the entire cell.
 
Upvote 0
As far as I know it cant, the indent applies to the entire cell.
Thanks, seems as if it has been a limitation of Excel VBA for some time. I saw posts asking to do this from 15 years ago.
 
Upvote 0
I wouldn't call it a limitation, Excel is not a word processing or DTP app.
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,090
Members
448,944
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top