Results 1 to 8 of 8

Thread: Automatically Insert Row

  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    12

    Automatically Insert Row

    Hi.
    But is this spreadsheet I'm trying to be automatically added rows.

    Eg

    In part that has "Locação de Equipamentos" ... when I, after filling out all the lines and need to add the item 6, I would like some command line that is automatically created and that all formulas of the previous line is it also .

    Same thing on the part of "Cessão de mão de obra"

    Thank you folks.
    Attached Files Attached Files

  2. #2
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    13
    Hi marreco,

    Could you please explain it more.

  3. #3
    Member Rajan_Verma's Avatar
    Join Date
    Sep 2011
    Posts
    81
    Rep Power
    13
    would be better if you can make it more clear

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    I would suggest you use a data table to do this.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    12
    Hi.
    imagine that I have a new item that will be inserted into the "LOCAÇÃO DO EQUIPAMENTO"
    Then in line 7 will always be shifted down so that the new item (5) is put.

  6. #6
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    13
    Step 1:- Create Name Range for Cell B8 and named it 'rngSubTotalPart1'
    Step 2:- Create Name Range for Cell B15 and named it 'rngSubTotalPart2'
    Step 3:- Press Alt + F11 -> Alt + I + M and Paste below code in the module

    Code:
    Const strPart1RangeName                 As String = "rngSubTotalPart1"
    Const strPart2RangeName                 As String = "rngSubTotalPart2"
    
    Sub InsertRowFor_LOCACAO_DO_EQUIPAMENTO()
    
        InsertRow strPart1RangeName
    
    End Sub
    
    Sub InsertRowFor_CESSAO_DE_MAODE_OBRA()
    
        InsertRow strPart2RangeName
    
    End Sub
    
    Sub InsertRow(ByVal strSubTotalRange As String)
    
        Dim wksSht                  As Worksheet
        
        If Application.ScreenUpdating Then Application.ScreenUpdating = False
        
        Set wksSht = ThisWorkbook.Worksheets("Plan1")
        
        With wksSht
            With .Range(strSubTotalRange).Offset(-1)
                If .Value = "" Then
                    MsgBox "Row Already inserted. May be it is not filled.", vbInformation, "Row insert..."
                    GoTo ErlyExit
                End If
                .EntireRow.Copy
                .EntireRow.Insert Shift:=xlDown
                Application.CutCopyMode = False
                If strSubTotalRange = strPart1RangeName Then
                    .Resize(, 5).Value = ""
                    .Offset(, 7).Value = ""
                    .Offset(, 10).Resize(, 2).Clear
                ElseIf strSubTotalRange = strPart2RangeName Then
                    .Resize(, 6).Value = ""
                End If
            End With
        End With
      
    ErlyExit:
        If Not Application.ScreenUpdating Then Application.ScreenUpdating = True
    
    End Sub

    Step 4:- Close This Window (Alt + F4)
    Step 5:- Insert a Shape and right click on it -> click on Assign Macro and assign InsertRowFor_LOCACAO_DO_EQUIPAMENTO macro from the macro list in the pop up window.
    Step 6:- Insert another shape, right click on shape, click on assign macro and assign InsertRowFor_CESSAO_DE_MAODE_OBRA macro to this one.
    Step 7:- Done
    Last edited by LalitPandey87; 12-21-2012 at 09:24 AM.

  7. #7
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    12
    Hi.

    after inserting a row, I can not insert any more line

    Thank you!!

  8. #8
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    13
    Replace the above code with this one

    Code:
    
    Const strPart1RangeName                 As String = "rngSubTotalPart1"
    Const strPart2RangeName                 As String = "rngSubTotalPart2"
    
    Sub InsertRowFor_LOCACAO_DO_EQUIPAMENTO()
    
        InsertRow strPart1RangeName
    
    End Sub
    
    Sub InsertRowFor_CESSAO_DE_MAODE_OBRA()
    
        InsertRow strPart2RangeName
    
    End Sub
    
    Sub InsertRow(ByVal strSubTotalRange As String)
    
        Dim wksSht                  As Worksheet
        
        If Application.ScreenUpdating Then Application.ScreenUpdating = False
        
        Set wksSht = ThisWorkbook.Worksheets("Plan1")
        
        With wksSht
            With .Range(strSubTotalRange).Offset(-1)           
                .EntireRow.Copy
                .EntireRow.Insert Shift:=xlDown
                Application.CutCopyMode = False
                If strSubTotalRange = strPart1RangeName Then
                    .Resize(, 5).Value = ""
                    .Offset(, 7).Value = ""
                    .Offset(, 10).Resize(, 2).Clear
                ElseIf strSubTotalRange = strPart2RangeName Then
                    .Resize(, 6).Value = ""
                End If
            End With
        End With
      
    ErlyExit:
        set wksSht = Nothing
        If Not Application.ScreenUpdating Then Application.ScreenUpdating = True
    
    End Sub
    Last edited by LalitPandey87; 12-21-2012 at 06:59 PM.

Similar Threads

  1. Automatically send Birthday E-Mail in Outlook
    By s.ajay88 in forum Outlook Help
    Replies: 2
    Last Post: 03-12-2013, 06:28 PM
  2. Copy Automatically Between Two Worksheets
    By marreco in forum Excel Help
    Replies: 0
    Last Post: 08-27-2012, 04:48 PM
  3. Create Bubble Chart Automatically
    By Excel Fox in forum Download Center
    Replies: 7
    Last Post: 08-12-2012, 10:39 PM
  4. help with after insert event in Access 10
    By richlyn in forum Access Help
    Replies: 9
    Last Post: 03-03-2012, 10:49 PM
  5. Insert 'n' number Rows after any specified row no.
    By LalitPandey87 in forum Excel Help
    Replies: 2
    Last Post: 11-08-2011, 08:59 AM

Posting Permissions

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