Solved

Indent column in excel VBA & Align to bottom

Posted on 2014-02-25
1
872 Views
Last Modified: 2014-02-25
I need to create vba code to indent 1 step in column P from row 2 down to the last row that has a value in column A. Can anyone shed some light on how I can do this?

I also need to have all my rows from row 2 down to the last row that has a value in column A to align to the bottom of the cells.
0
Comment
Question by:Lawrence Salvucci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
Harry Lee earned 500 total points
ID: 39886656
lsalvucci,

This should do the trick for you.

Sub IndentandBottomAlignColumnP()
Dim RW As Long, I As Long
RW = Cells(Rows.Count, 16).End(xlUp).Row

For I = 2 To RW
    If Cells(I, 1) <> "" Then
        Cells(I, 1).EntireRow.Select
        With Selection
            .VerticalAlignment = xlBottom
        End With
    End If
Next

With Range(Cells(2, 16), Cells(RW, 16))
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlBottom
    .AddIndent = False
    .IndentLevel = 1
    .ShrinkToFit = False
End With
End Sub

Open in new window

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

717 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