Closed Thread
Results 1 to 2 of 2

Macro for Adding new lines and colums ...

Hybrid View

  1. #1
    Registered User
    Join Date
    10-26-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    15

    Macro for Adding new lines and colums ...

    Hello all. I have not got any respond yet, so i may think i will try to give a more detailed description of what i want. I have attached an example before and after.
    I need some help with an excel sheet to generate new lines and columns based on the information in the sheet. I could do this manually but that will take a lot of time. The sheet have 129 lines plus heading and i guess my requested end-result will be between 1000 and 1500 lines + 3 new colums with new information.


    Here is what i wish to get done.
    I have som electrical cables which i will add more information to. Today my cables is identified like this:
    RFOU(i)250V 4x2x0,75 (there is also a lot of other information in the sheet, some of it nice to have). This is a cable with 4 groups of wires and two wires in each group. The square of the wires is 0,75mm2. The (i) in the "RFOU(i)250V" indicates that this cable have a screen (protects the signals from interferrence from outside) for each group (individual). If (c) in "RFOU(c)250V" indicate that the cable have a collective screen, one screen for all the groups.

    I need to implement what is the colour for each wire. Therefor today one line eg. RFOU(i)250V 4x2x0,75 will expand to 4x2+4=12 lines with also 3 new colums: "Group no", "Wire no" and "Wire Colour"
    Wire colour always follow this pattern:
    No. wire = 2 : BK – BU
    No. wire = 3 : BK - BU - BN
    Screen : S

    This must be some kind of macro programming rule:
    Screen = Individual, Set Group no to 001, 002, 003 (following the "Number of Groups") etc, Wire no to 0 and wire colour to S
    Screen = Collective, Set Group no to 000, Wire no to 0 and wire colour to S.


    Add new columns: "Group no", "Wire no" and "Wire Colour"


    Add new lines in according to condition in column c (screen), column H (Number of groups) and column I (No. Wires).
    Conditions:
    Add new lines in accordance to "Number of Groups", "No. Wires" and "screen".
    If screen is Individual and "Number of Groups"=2, "No. Wires"=3 amount of new lines will be:
    "Number of Groups" x "No. Conductors" + "Number of Groups" -->8
    Insert same data in the new rows, but set (Column W) "Group no" to 001, (Column X) "Wire no" to 0 and (Column Y) "WIRE COLOUR" to S.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 1 and (Column Y) WIRE COLOUR to BK.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 2 and (Column Y) WIRE COLOUR to BU.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 3 and (Column Y) WIRE COLOUR to BN.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 0 and (Column Y) WIRE COLOUR to S.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 1 and (Column Y) WIRE COLOUR to BK.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 2 and (Column Y) WIRE COLOUR to BU.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 3 and (Column Y) WIRE COLOUR to BN.


    If screen is Collective and "Number of Groups"=2, "No. Wires"=3 amount of new lines will be:
    "Number of Groups" x "No. wires" + "1" -->7
    Insert same data in the new rows, but set (Column W) Group no to 000, (Column X) Wire no to 0 and (Column Y) WIRE COLOUR to S.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 1 and (Column Y) WIRE COLOUR to BK.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 2 and (Column Y) WIRE COLOUR to BU.
    For the next line set (Column W) Group no to 001, (Column X) Wire no to 3 and (Column Y) WIRE COLOUR to BN.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 1 and (Column Y) WIRE COLOUR to BK.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 2 and (Column Y) WIRE COLOUR to BU.
    For the next line set (Column W) Group no to 002, (Column X) Wire no to 3 and (Column Y) WIRE COLOUR to BN.


    Hope for some assistance:-)

    Example before and after attached.
    Attached Files Attached Files
    Last edited by sknifseht; 04-09-2013 at 05:27 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro for Adding new lines and colums ...

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1