How to add new row dynamically in SSRS?

How can I create a VBA script to insert row ("add button") in Excel?

  • I have a huge document where users can Add, Delete and Change. A column shows the latest made changes by default (thus, only shows Add and Change). Delete results in a lock of a row (the deletion is managed in another document). Change makes a specific field in a specific column editable. I need an Add-functionality. How do I Do?

  • Answer:

    Here's another example that's pretty similar... main difference is it autofills some values from the previous row Sub AddRow1() ActiveSheet.Unprotect Application.ScreenUpdating = False Dim r As Integer Dim nLastRow As Integer 'Find the last row. In this case it contains the word "TOTAL" in the first column For r = 12 To 100 'Yes. I just hard-coded a number because I'm lazy. You can do better If ActiveSheet.Cells(r, 1).Value = "TOTAL" Then nLastRow = r Exit For End If Next Dim sInput As String sInput = InputBox("Enter the number of Rows to add:", "Add Rows", 1) If Trim(sInput) <> "" Then If CInt(sInput) Then For i = 1 To CInt(sInput) 'insert cells below last row For c = 1 To 7 ActiveSheet.Cells(nLastRow, c).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove ActiveSheet.Range(Cells(nLastRow - 1, c), Cells(12, c)).AutoFill Destination:=ActiveSheet.Range(Cells(nLastRow, c), Cells(12, c)) ActiveSheet.Cells(nLastRow, 1).ClearContents ActiveSheet.Cells(nLastRow, 2).ClearContents ActiveSheet.Cells(nLastRow, 4).ClearContents ActiveSheet.Cells(nLastRow, 5).ClearContents Next Next End If End If Application.ScreenUpdating = True ActiveSheet.Protect End Sub

Dave Wolf at Quora Visit the source

Was this solution helpful to you?

Other answers

I made a template with checkboxes :                            Adding Blank Rows and Columns with Checkboxes            You can add blank rows and blank columns with checkboxes in this template.Those rows and columns can be removed with checkboxes http://merkez-ihayat.blogspot.com/2015/09/adding-blank-rows-and-columns-with-vba.html

Kadr Leyn

Not sure if this is what you're looking for, but these macros prompt the user for a row above/below which a new row is inserted, after testing the input value for an empty string. Sub addRowBelow() Dim row row = InputBox("Row number below which new row will be inserted", "Input row number") If Not row = vbNullString Then ActiveSheet.Range("A" & row + 1).EntireRow.Insert End If End Sub Sub addRowAbove() Dim row row = InputBox("Row number above which new row will be inserted", "Input row number") If Not row = vbNullString Then ActiveSheet.Range("A" & row).EntireRow.Insert End If End Sub

Christofer Pak

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.