Solved

Indent column in excel VBA & Align to bottom

Posted on 2014-02-25
1
783 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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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 how to use a scrolling table in Microsoft Excel using the INDEX function.

772 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

16 Experts available now in Live!

Get 1:1 Help Now