How to add empty rows to the JQGrid?

How to write a macro in Excel to add "x" amount of rows.?

  • I want to write a macro that will look at the last row used on a worksheet and add "x" amount of rows below the last used row where "x" is the result of a cell in another worksheet within the same spreadsheet. Example: Last row used on Sheet 1! is 206 and in row 208 I have a totals line. I want to add rows in between row 206 and 208 where the number of rows to add is derived from a subtotal formula in Sheet 2! cell a110. What would the code for this macro look like? Any help would be appreciated. Thanks.

  • Answer:

    try this... Sub InsertRows() Dim NumberofRows, LastRow As Integer NumberofRows = Worksheets("Sheet2").Range("A110").Value LastRow = Worksheets("Sheet1").Range("A1"). _ End(xlDown).Row Rows(LastRow + 1 & ":" & LastRow + NumberofRows).Insert shift:=xlDown End Sub

Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

try this... Sub InsertRows() Dim NumberofRows, LastRow As Integer NumberofRows = Worksheets("Sheet2").Range("A110").Value LastRow = Worksheets("Sheet1").Range("A1"). _ End(xlDown).Row Rows(LastRow + 1 & ":" & LastRow + NumberofRows).Insert shift:=xlDown End Sub

James

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.