Consulting

Results 1 to 3 of 3

Thread: Need Help Inserting Row & Maintaining Format

  1. #1
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location

    Need Help Inserting Row & Maintaining Format

    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.

  2. #2
    VBAX Regular Maui_Jim's Avatar
    Joined
    Sep 2008
    Location
    Tampa, Florida
    Posts
    9
    Location
    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).

    [vba]
    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
    [/vba]

    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
    To the Optimist, the glass is half full. To the Pessimist, the glass is half empty.
    To the Engineer, the glass was designed to be twice as big as it needs to be.

  3. #3
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •