Results 1 to 5 of 5

Thread: How to insert random lines

  1. #1
    Join Date
    Nov 2009
    Posts
    37

    How to insert random lines

    Hello to all. I am looking for a way to insert 3 lines automatically whenever the column "Group" consist of the group name that is different from the previous line. Group names have letters, numbers and some special characters. I have Microsoft Office 2007 installed on my computer. Can anyone of you help me to get this?

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: How to insert random lines

    You mean when you take another name for online group three interrelated or you want to scan the file (sorted by group) and each change in value of the cell group to get three lines?

  3. #3
    Join Date
    Nov 2009
    Posts
    37

    Re: How to insert random lines

    The file currently contains 550 lines without spaces. The group "ABC" is in column E on lines 4,5 and 6. The group "DEF" is currently on lines 7 and 8 ... . I try to make 3 lines added what is currently on line 7 and following 3 lines below. Then the same thing after the group "DEF" to be made to lines 10 and 11 following the addition of 3 lines of the first group. There are currently 82 different groups in column E. So there will be 82 X 3 lines to add.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,022

    Re: How to insert random lines

    It can be done by macro. Basically, for each row (other than the first if you start at line 1), if you look inside the line = content of the previous line and that inside the <> "" (if not at the end of your three vacuum line, you're going to put 3 others), whether you spend the next, if you insert 3 lines

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: How to insert random lines

    Code:
    Sub insertline ()
     Dim a,t
     t = Range ( "a65535"). End (xlUp). Row 
     For a = 2 To t
     If Cells (a, 1). Value <> Cells (a - 1, 1). Value Then 
     Range (Cells (a, 1), Cells (a + 2, 1)). EntireRow. Insert 
     t = t + 3 
     a = a + 3 
     End If
     Next
     End Sub

Similar Threads

  1. Replies: 4
    Last Post: 13-01-2012, 05:07 PM
  2. Why are T1 lines so expensive?
    By Shakaal in forum Networking & Security
    Replies: 4
    Last Post: 16-09-2010, 12:18 PM
  3. Create .bat and insert lines from .vbs
    By Micka in forum Software Development
    Replies: 3
    Last Post: 08-05-2010, 07:48 PM
  4. How to use "Math.random()" to generate a random number in JavaScript?
    By Silent~Kid in forum Software Development
    Replies: 5
    Last Post: 03-02-2010, 05:06 AM
  5. How to use sed to insert lines in a file
    By McGrawh in forum Software Development
    Replies: 2
    Last Post: 24-06-2009, 11:45 PM

Tags for this Thread

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
  •  
Page generated in 1,713,572,190.82761 seconds with 16 queries