Auto format sheet

C

C

I have a spreadsheet that I continously have to format. It is a data dump
from another application. It could be any number of rows and any number of
columns. I need a macro that will look at column A and format B based on
the number in Column A. So if Column A is 2 then indent Col B 5 spaces, if
Col A is 3 then indent Col B 10 spaces, if Col A is 4 then indent Col B 15
spaces. Also if Col B is Bold then shade row Gray.

Thanks in advance for your help.
clv
 
C

C

Paul,

This is perfect. Thank you so much.

clb

Paul said:
The following code should work:



Sub reformat()
Dim i As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Cells(i, 1).Value >= 2 And Cells(i, 1).Value <= 4 Then
Cells(i, 2).Value = Space(5 * (Cells(i, 1).Value - 1)) & Cells(i, 2).Value
End If
If Cells(i, 2).Font.Bold = True Then Cells(i, 2).EntireRow.Interior.ColorIndex = 15
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top