Solved

Indent column in excel VBA & Align to bottom

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

810 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