Consulting

Results 1 to 9 of 9

Thread: Solved: insert row to Seperate Data Groups

  1. #1
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    294
    Location

    Solved: insert row to Seperate Data Groups

    Hi

    I have a macro alreday in place but cannot figure out how to add the following step.

    Is it possible to insert a row after each highlighted country header in columns b.

    so starting at row 9 column space between egypt data and finland then,

    a space between finland data and Kazakhstan.....

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Where's the code? What you gave does nothing.
    ____________________________________________
    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
    Aug 2007
    Posts
    294
    Location
    hay!!!

    is it not in module 1.....ok my mistake then here it is

    Sub specialmacro()
    Dim rng As Range
    Dim str1 As String
    Dim str2 As String
    Dim rowe As Long
    rowe = 5
    str1 = "B"
    str2 = "B"
    With Sheets("Sheet1")
    Set rng = Range(.Cells(rowe, str1), .Cells(.Cells.Rows.Count, str2).End(xlUp))
    End With
    rng.SpecialCells(xlCellTypeBlanks).Select
    Selection.Rows.EntireRow.Delete
    End Sub

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is the code, but as I said it does nothing, it errors.

    Are you simply asking for code to insert those blanks, I thought you wanted it added to some code that yoou had.
    ____________________________________________
    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

  5. #5
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    294
    Location
    I thought you wanted it added to some code that you had. - yes i do or a seperate bit of code will do to i can call it.

  6. #6
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    294
    Location
    can this be done?

  7. #7
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    294
    Location
    ok here is my shot at the code......but i keep on getting a compile error....


    Sub specialmacro2()
    Dim adr As String
    Range("B5").Select
    adr = Range(Selection, Selection.End(xlDown)).Address(RowAbsolute:=False, ColumnAbsolute:=False)
    For Each c In Range(adr).Cells
    If c.Offset(RowOffset:=0, ColumnOffset:=-1).Value = "" Then
    c.Clear
    End If
    Next c
    End Sub

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub specialmacro()
    Dim rng As Range
    Dim LastRow As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")

    LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    Set rng = .Range("A6").Resize(LastRow - 5)
    Set rng = rng.SpecialCells(xlCellTypeBlanks)
    For i = LastRow To 6 Step -1

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

    .Rows(i).Insert
    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

  9. #9
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    294
    Location
    ok i see the error...

    thanks xld once again fro your feedback...

Posting Permissions

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