Consulting

Results 1 to 5 of 5

Thread: Solved: Insert lines after so many rows

  1. #1
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location

    Solved: Insert lines after so many rows

    How do you insert lines after every: i) 1 line, ii) 2 lines using the mod function?

    I have data in Excel say from 1 to 1000. I wanted to use the mod function because it should be easy to change the base to change the number of lines in between the insert.

    If the is an easier way that is easily editable then great
    Last edited by sassora; 03-20-2008 at 01:16 AM.

  2. #2
    You mean, new rows into a table?
    Or new lines into a text file?
    Are you sure you want to do it using the mod operator? There might be simpler solutions.
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Something like
    [VBA]
    Sub InsertRows()
    Dim i As Long, Space As Long
    Space = InputBox("What grouping?")
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
    If i Mod Space = 0 Then
    Cells(i, 1).EntireRow.Insert
    End If
    Next
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    Yes exactly like that! Thanks

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sassora,
    If this is Solved, you can mark it so using the Thread Tools dropdown.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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