PDA

View Full Version : Need Help Inserting Row & Maintaining Format



dawaro
09-09-2008, 08:15 PM
I have a spreadsheet that is used as a list work orders for a project that tracks the status using the count function and I need to be able to assign a command button to add a row to the bottom of the list and maintain the formatting and formulas.
I am working in 2003 and I have tried every combination of vba I could find and tried building multiple macros but nothing has worked.
I have attached a condensed copy of the file and would greatly appreciate if someone could bail me out here.

Maui_Jim
09-10-2008, 04:24 PM
I have added a Command Button to your spreadsheet sample with the following Click Event code. (I also include the code as a macro, in case that is an option for you).


Private Sub CommandButton1_Click()
Range("A65536").End(xlUp).Select
With Selection.EntireRow
.Insert
.Copy Destination:=.Offset(-1, 0)
On Error Resume Next
.SpecialCells(xlCellTypeConstants).ClearContents
On Error GoTo 0
End With
End Sub

This code will insert a new row just above the row of totals and black separation line. It will also copy the formats and formulas from the row above.

Helps this helps,
Jim

dawaro
09-10-2008, 05:51 PM
Thanks for the help Maui_Jim, that is exactly what I needed. I am in the process of reading some books on this stuff to learn how to do it on my own but this is one of those items I needed right away. Thanks for bailing me out.