Insert New Row with auto formatting.

A

aussiegirlone

I have a formula here that automatically inserst a new row and formats the
text in it bold.
I would like this newly inserted row to automatically be formatted to have
the cells AC:AF formatted with a thin line boarder and fill color Aqua. Can
anyone help with the code please
Thank you in advance

Sub NewRow()

EndRow = Cells(Rows.Count, 1).End(xlUp).Row
n = Cells(Rows.Count, "AF").End(xlUp).Row + 1
Cells(n, "AC").Value = "TotalHours"
Cells(n, "AF").Formula = "=sum(AF1:AF" & n - 1 & ")"
Union(Cells(n, "AF"), Cells(n, "AC")).Font.Bold = True
End Sub
 
F

FSt1

hi
add this at the end of your code for the color and line. i am not sure what
your definition of "Aqua" is so i guessed.
Union(Cells(n, "AF"), Cells(n, "AC")).Interior.ColorIndex = 28
Union(Cells(n, "AF"), Cells(n, "AC")).Borders.LineStyle = xlContinuous
Union(Cells(n, "AF"), Cells(n, "AC")).Borders.Weight = xlThin

see this site for other colors.
http://www.mvps.org/dmcritchie/excel/colors.htm

regards
FSt1
 

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