Results 1 to 7 of 7

Add a row, copy formulas, and formatting

Threaded View

  1. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Add a row, copy formulas, and formatting

    Hello sp135,

    I have created an example workbook. This has a button below the first entry on row 8. Clicking the button will add a new row. There are named ranges on the sheet "Named Ranges" for the drop down validation and the starting sequence number. This is computed by subtracting 7 from the current entry row. Since the first entry row is 8, the line item number equals 1. Here is the macro called by the button.
    Sub AddRow()
    
      Dim Cell As Range
      Dim CmdBtn As OLEObject
      Dim Rng As Range
      
        Set CmdBtn = ActiveSheet.OLEObjects("CommandButton1")
        Set Rng = CmdBtn.TopLeftCell.Offset(-1, 0).Resize(1, 7)
        
          CmdBtn.Top = CmdBtn.TopLeftCell.Offset(1, 0).Top + 3
          Rng.Copy Rng.Offset(1, 0)
            
          For Each Cell In Rng.Offset(1, 0)
            If Not Cell.HasFormula Then Cell = ""
          Next Cell
          
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1