+ Reply to Thread
Results 1 to 2 of 2

Insert number of rows by a number in the cell

Hybrid View

  1. #1
    Registered User
    Join Date
    11-14-2016
    Location
    Brighton, United Kingdom
    MS-Off Ver
    MS Office 2016
    Posts
    1

    Insert number of rows by a number in the cell

    Hello gurus,

    Sorry if something similar has been answered here already - I tried to search for it but I did not succeed.

    Let's keep it very simple: I have a number (1, 2, 3, 4, ..., n) and based on this number I need to insert number of rows. (Number "5" in Sheet1.Range(A1) => Insert 5 new rows in Sheet2 from Rows(20:20). Number "8" in Sheet1.Range(A1) => Insert 8 new rows in Sheet2 from Rows(20:20). Number "15" => insert 15 new rows etc.)

    Does it make sense?

    Thank you.

    Filip

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Insert number of rows by a number in the cell

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        If Target <> vbNullString Then
            With Sheets("sheet2")
                .Range("A20").Resize(Target.Value).EntireRow.Insert
            End With
        End If
    End If
    End Sub
    Kind regards
    Leo

+ 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. Replies: 7
    Last Post: 10-14-2016, 05:33 PM
  2. Replies: 2
    Last Post: 09-11-2016, 12:40 PM
  3. Replies: 2
    Last Post: 09-11-2016, 12:39 PM
  4. Replies: 1
    Last Post: 09-11-2016, 12:39 PM
  5. [SOLVED] insert a number in sheet1, add that number of rows in sheet2 and sheet3
    By dishguy05 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-07-2014, 04:55 PM
  6. [SOLVED] insert rows based on number in cell and copy the data down into the new rows
    By pziefle in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-05-2013, 11:19 AM
  7. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 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