+ Reply to Thread
Results 1 to 22 of 22

Write multiple lines from one line

  1. #1
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Write multiple lines from one line

    I am using a macro to copy rows from one sheet to another, but I want more than that.
    On the sheet "PROGRAMA COBRE" is the No. Spools is greater than 1, I want you to write that line (ID, No. Spools = 1 and Packing Unit) that number of times.

    example:

    On the second line have:

    ID Nº Spools Packing Unit
    B0007X02480CU-S 10 120000

    I want you to write this line 10 times, where the number of spools happens to 1 in all of them:


    ID Nº Spools Packing Unit
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000
    B0007X02480CU-S 1 120000


    Please find attached my file so they can see what I've done.

    http://speedy.sh/swzPR/test1.xlsx


    Thanks

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Write multiple lines from one line

    I have no interest in an a 9mb sample file. Please attach a sample file here to this thread.

    Make sure there is just enough data to demonstrate your need, perhaps 5-10 sample starting rows. Include a BEFORE sheet and an AFTER sheet in the workbook to show the results to automate.

    Remember to desensitize the data if necessary.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    Try this
    Change Sheet references as required

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by JBeaucaire View Post
    I have no interest in an a 9mb sample file. Please attach a sample file here to this thread.

    Make sure there is just enough data to demonstrate your need, perhaps 5-10 sample starting rows. Include a BEFORE sheet and an AFTER sheet in the workbook to show the results to automate.

    Remember to desensitize the data if necessary.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Thanks for reply. Now only has 5 lines, but continues with almost 9MB.
    Right now I can not upload through the paperclip, sorry.


    EDIT:
    Upload file:

    Livro2.xlsm
    Last edited by asm19; 08-25-2015 at 04:24 AM.

  5. #5
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    Try this
    Change Sheet references as required

    Please Login or Register  to view this content.
    Thanks for reply. Yes, its works!

    Please Login or Register  to view this content.
    Thank you.

  6. #6
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    Try this
    Change Sheet references as required

    Please Login or Register  to view this content.
    One more question, this time I am inserting in new sheet (column A:C), but how can I set to insert in column B:D? This is because I want you to increment a value in column A.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    I don't quite understand your last question.
    Attach a small workbook with a before and after.

  8. #8
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    I don't quite understand your last question.
    Attach a small workbook with a before and after.
    See Image:

    1.png
    Basically I want the data:

    Column A pass to the column C;
    Column B pass to column A;
    Column C pass to column B.

    Understand?

    Another issue, tried to make a loop that increments up 1 unit on No. Order. Amounting in value I get this:

    Today Date + 001

    It is still not working as I want because it is not to increase 1 unit and is always: 20150825002
    File in attach.


    Thanks
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    You state:
    Column A pass to the column C;
    Column B pass to column A;
    Column C pass to column B.

    In your attachment it is
    ID = Column A in Sheet1. In Sheet2 = Column C. OK
    No Spools = Column B in Sheet1. In Sheet2 = Column D (Not Column A as you state)
    Delivery Length = Column C in Sheet1. In Sheet2 = Column E (Not Column B as you state)

    Take your time and let us know what it is.

    How do you want to increase the No. Order?
    They are not numbers.

  10. #10
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    The ID is: B0007X0****CU-S
    The No Spools is: column B in Sheet1 and column D in Sheet2
    Delivery Length is Column C in Sheet1. In Sheet2 = Column E

    the code is doing what I want, there is a bad thing.

    See the previous screenshot again, and now see this:

    2.png

    In this screenshot you can see how I want the data because as they were previously, they were in the wrong column, understand?

    "How do you want to increase the No. Order?"

    Simple, right now I was using today date more "001" in the first line, and the remaining increase always + 1. This why? The order number must always be different from previous ones.
    I was previously doing this manually, where the first line would be today date + 001 and incremented in the following.
    Example in column A:

    Please Login or Register  to view this content.
    I can keep doing this manually, but if possible I wanted to leave everything automatic.
    You have any different idea?
    Thank you
    Attached Images Attached Images

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    Let us know what changes you want made in the attached.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Yes, it works fine and can look like this. I noticed that you use an array to insert, how can I do to enter the remaining data?

    Due Date = Today Date
    QuantityUnit = M
    Type = Order
    Remark = Clear
    StorageLocation = POGU01
    ItemNo = 1

    I can not get this to work in array.
    Thanks

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    In my last attachment, change the code to this.


    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Yes, that's right. Thank you.
    + Reputation for you

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    Thanks for letting us know and for the rep.
    Good luck

  16. #16
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    Thanks for letting us know and for the rep.
    Good luck
    I have one more question
    With all the data on the sheet 2, I export to xml, but I have a problem. I am creating a table and set the fields for the xml (data_map), but every time you generate new data have to build this table and the "map". There is possibility to block this formatting, not to be changed? Or maybe keep unchanged headers and fill only with data from line 2?
    Thanks

  17. #17
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    I'm sorry asm19. I don't know anything at all about that.
    Maybe start a new thread so you'll get an answer from someone who knows about this.

    Sorry about that.
    Good luck

  18. #18
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    I'm sorry asm19. I don't know anything at all about that.
    Maybe start a new thread so you'll get an answer from someone who knows about this.

    Sorry about that.
    Good luck
    Ok, no problem. Thanks for your help.

  19. #19
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Write multiple lines from one line

    Attached increases the ID numbers also.
    I think that's what you wanted isn't it?
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Quote Originally Posted by jolivanes View Post
    Attached increases the ID numbers also.
    I think that's what you wanted isn't it?
    no jolivanes, version 3 is working as I want. I do not want to increase the ID. I lack only the part of the XML.
    Thank you anyway

  21. #21
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    If you have a new sheet named "XML" that is already formatted with headings and "data_map" XML, if you copy the data sheet "CreateOrders" using a "Copy to Sheet XML" button to XML sheet, from the line 2 down you think you can keep the entire table format? What do you think about this?
    Follows the file with what I am talking about.

    Livro3_v2.xlsm


    EDIT:

    I could already do what I wanted, but I have a problem.
    The number of orders is not always the same, but can be can be less. When you copy orders to the XML file, if more than the table size, then no problem increases table. The problem is if it is less, when exporting to XML to export the last lines in white, of course I can eliminate these lines manually, but wondered if it is possible to remove blank rows in the table automatically?
    File:

    Livro 3 - Send.xlsm

    EDIT2:

    I took care of my problem and is working as I want.
    Last question, you know how to lock the position of the buttons so they can not be moved?
    Thanks

    Livro3 - Send.xlsm
    Last edited by asm19; 08-27-2015 at 09:55 AM.

  22. #22
    Registered User
    Join Date
    08-24-2015
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    31

    Re: Write multiple lines from one line

    Hello @jolivanes

    I want to add one more thing, and would like you to help me up. Basically I want to add a field "Due Date". Before I was putting the "Today Date" in all fields, but now want to put a specific date depending on an ID. See my example:

    From:
    1.png

    To:
    2.png


    I did manually, put all the dates "by hand", but how can I do this automatically?
    Thank you for help.

    File
    Livro3.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Textbox: write and change different lines, get values of each line
    By pclaesen in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-24-2015, 09:29 AM
  2. Multiple Lines into One Line
    By yoshilily in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-02-2012, 07:13 AM
  3. Line Graph: multiple lines from multiple data sets?
    By Guerodemonio in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 05-28-2011, 06:15 AM
  4. Multiple lines to one line
    By Ron1121 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-28-2009, 03:04 PM
  5. [SOLVED] select lines from multiple worksheets and write to new worksheet
    By rem in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-15-2005, 11:05 AM
  6. [SOLVED] Write code to insert multiple lines
    By Frantic Excel-er in forum Excel General
    Replies: 0
    Last Post: 06-16-2005, 08:05 PM

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