Consulting

Results 1 to 4 of 4

Thread: Solved: Inserting rows through a button

  1. #1

    Solved: Inserting rows through a button

    I know that this is simple, but I jsut wanted to ask questions before I got started to make sure that I am not missign anything. There are three data tables on this sheet. If a user needs more rows they press the button. It copies the formatting from a sheet called data and then it inserts a blank row identical in formatting to the rest of the table and then. pastes in the formatting so the user can fill it in. The reason that I am doing this is becuase I am trying to get to the point where they can lock it down and there is not way that they would ever need to insert anything else into the sheet manually. I know that I am going to need to use dynamic cell references on the tables since the rows above could increase. Just want to make sure that I am correct in assuming this and not missing anything.


    Thanks,
    Chris

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Chris,
    I really don't like your use of merged cells in the addition column, but you can insert rows and copy down to achieve your object.
    For Personnel
    [VBA]
    Option Explicit
    Option Compare Text

    Private Sub CommandButton1_Click()
    NewPersonnel
    End Sub

    Sub NewPersonnel()
    Dim Cel As Range
    Set Cel = Sheets("Sheet1").Columns(1).Find("Equipment Rental").Offset(-1)
    With Cel.Resize(, 15)
    .Insert Shift:=xlDown
    .Offset(-1).FillDown
    .Offset(-1).Resize(, 5).ClearContents
    .Offset(-1, 6).Resize(, 5).ClearContents
    End With
    Cel.Offset(, 11).Formula = "=SUM(L3:M" & Cel.Row - 1 & ")"
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    I did not to the inital design of the forms and the problem is that there are too many different types of data within this workbook. This almost a 60 sheet workbook and I am not going to go back and redo all the sheets. They have been formatted and rebuilt so many times it is not true. That is only part of the sheet. There are three other data tables above that section. As a matter of preference I would agree with you to do away with the merged cells, but at this point it is easier to live with them at least until they decide to do antoer major rebuild which I am hoping will take everything into VB.NET. Only time will tell though.

    Thanks,
    Chrsi

  4. #4
    Thanks for the help, this thread is solved

Posting Permissions

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