+ Reply to Thread
Results 1 to 13 of 13

Insert multiple empty rows

  1. #1
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Insert multiple empty rows

    Ladies and Gentlemen,

    Every week i get a very big excel file, with about 2000 rows.
    I need to insert 4 empty rows between all different values in Column A.
    I have a macro wich works, but it inserts only one empty row, and
    I cant find a way to insert 4 rows. Maybe somenone can explain where
    in der formula i need to write in to insert 4 empty rows, instead 1?

    My macro code for this is:

    Option Explicit

    Sub insert()
    Dim lngI As Long
    For lngI = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
    If Cells(lngI, 1) <> Cells(lngI - 1, 1) Then Rows(lngI).Insert Shift:=xlDown
    Next
    End Sub



    INSERT EMPTY ROW.jpg

    Afterwards i need to paste some datas and formulas in these empty rows.
    Is it possible to do this with VBA, too?

    I hope that i could explain my concern understandeble, my english is not the best.

    cheers

    mandura

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Insert multiple empty rows

    Here!

    Please Login or Register  to view this content.
    "Afterwards i need to paste some datas and formulas in these empty rows.
    Is it possible to do this with VBA, too?"

    Can be done, but need Inputs as to what you want?
    Last edited by NeedForExcel; 03-25-2015 at 06:32 AM.
    Cheers!
    Deep Dave

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

    Re: Insert multiple empty rows

    Please use code tags when posting. Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Insert multiple empty rows

    This should do the first bit !!
    Please Login or Register  to view this content.
    Regards Mick

  5. #5
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    Thank you very, very much!!

    it works perfectly, after a little change.

    in the first row of your formula you forgot to write a "r" down
    after this little repair it still wasnt working.

    after deleting "Rows" from "Sub InsetRows()" it finaly worked.

    the vba code that i need is finaly:

    Sub Insert()
    Dim LR As Integer, Counter As Integer
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    For Counter = LR To 2 Step -1
    If Cells(Counter, 1) <> Cells(Counter - 1, 1) Then
    Rows(Counter & ":" & Counter + 3).Insert Shift:=xlDown
    End If
    Next Counter
    End Sub


    thank you very much again mate!!!

  6. #6
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    Quote Originally Posted by MickG View Post
    This should do the first bit !!
    Please Login or Register  to view this content.
    Regards Mick
    Thanks for your reply, but unfortunately this is not the solution for my
    request. this code is inserting for empty rows after between every single row.
    i need 4 empty rows between rows were the data or value is different.

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Insert multiple empty rows

    @mandura - Glad it worked.. Sorry for the trouble!

    But the 2 issues you pointed out, not very sure about them.. :O
    Last edited by NeedForExcel; 03-25-2015 at 06:49 AM.

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Insert multiple empty rows

    Unfortunately I misread your requirements, but thank you for your courteous reply.

  9. #9
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    Quote Originally Posted by MickG View Post
    Unfortunately I misread your requirements, but thank you for your courteous reply.
    misreading can happen, but thank you for your effort anyway!

  10. #10
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    Quote Originally Posted by NeedForExcel View Post
    @mandura - Glad it worked.. Sorry for the trouble!

    But the 2 issues you pointed out, not very sure about them.. :O
    a little bit trouble, but a very big benefit for me!!

    thanks again!

  11. #11
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    Quote Originally Posted by JOHN H. DAVIS View Post
    Please use code tags when posting. Maybe:

    Please Login or Register  to view this content.
    i am sorry, but i dont understand? what are code tags?

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

    Re: Insert multiple empty rows

    Quote Originally Posted by mandura View Post
    i am sorry, but i dont understand? what are code tags?
    Please review the Forum Rules. Refer too Rule No. 3.

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

  13. #13
    Registered User
    Join Date
    03-25-2015
    Location
    Zagreb, Croatia
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Insert multiple empty rows

    my second need is to insert data and 2 formulas in these 4 empty rows.
    it would be great if anyone could help me.

    i need the auto sum i column "P", and in column "O" i want wo copy the
    number of the bill.

    example.jpg

    i hope this is possible with a macro code?

    i tried to insert a excel file, but i could not find a way to do it.

+ 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] vba insert empty rows into worksheets
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2014, 07:25 AM
  2. [SOLVED] Insert empty/blank rows
    By Danielle22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2013, 04:30 PM
  3. insert two empty rows below used data
    By johncena in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2010, 05:49 AM
  4. insert 1 empty row after 100 rows
    By vinz20k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2007, 03:52 AM
  5. Macro To Insert Empty Rows??
    By rtidrtid in forum Excel General
    Replies: 1
    Last Post: 02-03-2006, 11:20 AM

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