Consulting

Results 1 to 3 of 3

Thread: Solved: Insert an empty line between interval

  1. #1
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location

    Solved: Insert an empty line between interval

    Hi.

    I need to insert empty rows based on a criteria in cell 'A1'

    example
    is' A1 'is equal to 3 then will be inserted between the range three lines "A2: G10'
    I tried this but not working
    [VBA]Sub Insert_Blank_Rows()

    'Select last row in worksheet.
    Selection.End(xlDown).Select

    Do Until ActiveCell.Row = Range("A1").Value
    'Insert blank row.
    ActiveCell.EntireRow.insert shift:=xlDown
    'Move up one row.
    ActiveCell.Offset(-1, 0).Select
    Loop

    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]Sub Insert_Blank_Rows()
    Dim lastrow As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With ActiveSheet

    lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = lastrow To 1 Step -1

    If IsNumeric(.Cells(i, "A").Value) Then

    If .Cells(i, "A").Value > 0 Then

    .Cells(i + 1, "A").Resize(.Cells(i, "A").Value, 7).Insert shift:=xlDown
    End If
    End If
    Next i
    End With

    Application.ScreenUpdating = True
    End Sub
    [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location
    Hi.

    Was Great!!!

    Thank you!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •