+ Reply to Thread
Results 1 to 5 of 5

insert two empty rows below used data

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Post insert two empty rows below used data

    Sub Insert2Rows()
    Dim c As Long, lrow As Long
    With ActiveSheet
    lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    
    For c = lrow - 1 To 1 Step -1
    If .Cells(c, 1).Value <> "" Then
    If .Cells(c, "A").Value <> .Cells(c + 1, "A").Value Then
    .Cells(c + 1, "A").Resize(2).EntireRow.Insert
    End If
    End If
    
    Next
    End With
    
    End Sub
    dear friends i have found above macro from net & it's inserting empty rows base on column "A" data change,my data starting in column "A" row 2 to down.i want to insert column "A" data available all rows below two empty rows.pls help me to do that....
    Last edited by johncena; 07-01-2010 at 05:49 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: insert two empty rows below used data

    Hello johncena,

    Can you give us an example of how the data should look before and then how it should look after the macro is run?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Re: insert two empty rows below used data

    Quote Originally Posted by Leith Ross View Post
    Hello johncena,

    Can you give us an example of how the data should look before and then how it should look after the macro is run?
    thanks for your reply friend.here i have attached my sheet.first sheet is my normal data & second sheet is i expected data.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: insert two empty rows below used data

    Hello johncena,

    I have add the macro below to the attached workbook. There is a button above "Date" in column 1 to run the macro.
    Sub Add2Rows()
    
      Dim R As Long
      Dim Rng As Range
      Dim RngEnd As Range
      Dim Wks As Worksheet
      
        Set Wks = Worksheets("Sheet1")
        
        Set Rng = Wks.Range("A2")
        Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
        
        If RngEnd.Row < Rng.Row Then Exit Sub
        
        Set Rng = Wks.Range(Rng, RngEnd)
        
        Application.ScreenUpdating = False
        
          For R = Rng.Rows.Count To 2 Step -1
            Rng.Rows(R).Resize(RowSize:=2).EntireRow.Insert
          Next R
        
        Application.ScreenUpdating = True
        
    End Sub
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Re: insert two empty rows below used data

    thanks a lot Leith Ross.it's work very well.REP+

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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