+ Reply to Thread
Results 1 to 4 of 4

Insert n-1 rows including formulas

  1. #1
    Registered User
    Join Date
    09-15-2014
    Location
    Cologne, Germany
    MS-Off Ver
    2013
    Posts
    2

    Insert n-1 rows including formulas

    Hello everyone,

    I am new to this forum and have a question concerning a macro to which I cannot find a solution.

    I am using Excel 2013.


    Problem: I have a file with data to various IDs. Each ID can have numerous seasons ranging from 1 to n. The data comes from various other sources using VLOOKUP etc.

    What I want to do is to automatically insert n-1 rows beneath each ID copying all data including formulas from the respective row.

    The value for n is found in each row, f.ex. ID: 1001 Seasons: 1; ID: 1002 Seasons: 5

    The following macro works fine, BUT it inserts n(!) rows and not n-1. Seeing as there already exists a row I need to only enter n-1.


    F.ex. ID: 1001 -> enter 1-1=0 rows; ID: 1002 -> enter 5-1=4 rows.

    It's a small bug, but it's been driving me mad. Maybe I need a whole new macro, I don't know...

    In Row 1 there are the headers and in column C the number of seasons is entered:


    Sub EnterRowswithformulas()
    Dim RowNo As Long, InsertRows As Long
    RowNo = 2
    Do
    InsertRows = Range("C" & RowNo)
    Rows(RowNo + 1 & ":" & RowNo + InsertRows).Insert Shift:=xlDown
    Range("A" & RowNo & ":P" & RowNo + InsertRows).FillDown
    RowNo = RowNo + InsertRows + 1
    Loop Until Range("C" & RowNo) = ""
    End Sub


    Any help is greatly appreciated!

    Cheers!
    Attached Files Attached Files
    Last edited by Businessrocker; 09-16-2014 at 09:20 AM. Reason: Added File

  2. #2
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Insert n-1 rows including formulas

    Please attach sample file.

  3. #3
    Registered User
    Join Date
    09-15-2014
    Location
    Cologne, Germany
    MS-Off Ver
    2013
    Posts
    2

    Re: Insert n-1 rows including formulas

    Has anybody got an idea? Still looking for a solution... :-/

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert n-1 rows including formulas

    Please comply with Forum Rules when posting. Refer too Rule No. 3

    http://www.excelforum.com/forum-rule...rum-rules.html

    Maybe:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] how to insert rows including data from another sheet in same workbook
    By roofi in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-05-2013, 04:10 AM
  2. Dynamic Print Range not including blank rows with formulas
    By amartin575 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2013, 11:49 AM
  3. Insert Rows And Fill Formulas Copying rows
    By Mj_McKenzie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2012, 03:18 PM
  4. Replies: 5
    Last Post: 02-24-2011, 08:21 AM
  5. [SOLVED] Insert rows with Formulas
    By Doug Manning in forum Excel General
    Replies: 0
    Last Post: 09-16-2005, 01:05 PM

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