Solved

Indent column in excel VBA & Align to bottom

Posted on 2014-02-25
1
802 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

862 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

26 Experts available now in Live!

Get 1:1 Help Now