Consulting

Results 1 to 3 of 3

Thread: VBA code for inserting blank row in between the data points

  1. #1
    VBAX Newbie shekar's Avatar
    Joined
    Nov 2012
    Location
    india
    Posts
    3
    Location

    VBA code for inserting blank row in between the data points

    Hi All,

    I have a huge excel which contains lot of data points , here i want to find the particular data point and above that i want to insert a blank row.....my data as follows

    1 Sales Order
    2 minute
    3 Two
    4 second
    5 Three
    6 Sales Order
    7 minute
    8 Two
    9 second
    10 Three
    11 Sales Order
    12 minute
    13 Two
    14 second
    15 Three
    16 Sales Order
    17 minute
    18 Two
    19 second
    20 Three

    Here i want to find the "Sales order" and above that i want to insert a blank row....
    Attached Files Attached Files

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

    With ActiveSheet

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

    If .Cells(i + 1, "B").Value = "Sales Order" Then

    .Rows(i + 1).Insert
    End If
    Next i
    End With
    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 Newbie shekar's Avatar
    Joined
    Nov 2012
    Location
    india
    Posts
    3
    Location

    Thumbs up superb.......its working....thanks a lot

    Quote Originally Posted by xld
    [VBA]Sub ProcessData()
    Dim lastrow As Long
    Dim i As Long

    With ActiveSheet

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

    If .Cells(i + 1, "B").Value = "Sales Order" Then

    .Rows(i + 1).Insert
    End If
    Next i
    End With
    End Sub[/VBA]

Posting Permissions

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