+ Reply to Thread
Results 1 to 14 of 14

Generate sheets from template by rows and copying values to the template

  1. #1
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Generate sheets from template by rows and copying values to the template

    Hi all,

    I want to generate sheets from the template in the attachment. There's an example of how I want it to be generate.

    There are some rules like the amount of the sheets generate for each row is based on column P.

    Column J will be copy to the carton number in each sheets it will be increment say J2 = A then when it copy to the first sheet it will be A1 then A2 , A3 and so on until the last sheet of each row.

    Then column M and N have a lot of combinations.

    Column M is the 'Size' column normal it will have something like this in the cell '4-16' this is how we record the sizes and if there's a '-' in between the numbers it will always be an increment of 2 until the last number so for this it will be 4,6,8,10,12,14,16 and this information will be apply on the size part of the template.

    But sometime it will apply like this '4+8+10+12' if there's a size missing which in here is 6 then we always record it like this.

    There are size like S-XL and S+L which is the same concept so for 'S-XL it will mean S,M,L,XL and S+L means S,L and this is how I want the size column and the rules to be generate to the templates.

    For the 'breakdown' column N is quite similar to column M, here's an example of what values are like in column M '23+45+(76+23)+12'

    Each '+' sign indicate a different size so let say 23 is size 6, 8,10,12
    the brackets indicate that they are the same size. so 76 and 23 inside the bracket are both size 10
    How the size apply will be depends on size column like it could be '4+12+14+16' in size column and column N can still be '23+45+(76+23)+12'

    Then for the other columns for colour, PO and SKU it will need to be copy accordingly so let say if this row need to generate 4 templates it will need to be copy to the 4 templates as shown on my example in the attachment.

    Can this be done in vba?

    Thanks
    Attached Files Attached Files
    Last edited by HXIO; 06-03-2020 at 06:56 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    I'm sorry as I don't get exactly what you mean.

    For example :
    There are size like S-XL and S+L which is the same concept so for 'S-XL it will mean S,M,L,XL and S+L means S,L and
    this is how I want the size column and the rules to be generate to the templates.
    But in your sample workbook on each example sheet, the size is still a number, not a letter S or M or L, etc.

    I also see that column H and column P has the same value on each row.
    I wonder what is the possibility that "one day" the value on each row of column H is different than the value on each row of column P ?

    What I assume is (for example)
    Box : B
    Column size row value : 16-26
    while the value in Column QTY (same row) are : 17+31+(32+18)+31+25+6

    So if it's side by side, it becomes like this :
    BOX SIZE QTY
    B1....16......17
    B2....18......31
    B3....20......32
    B4....20......18
    B5....22......31
    B6....24......25
    B7....26......6

    Another example :
    Box M
    Column size, row value : 4+6+8+16
    Column QTY value : 16+(12+53)+57+16

    So if it's side by side, it becomes like this :
    BOX SIZE QTY
    M1....4.......16
    M2....6.......12
    M3....6.......53
    M4....8.......57
    M5....16.....16

    That's if I'm not mistaken what you mean.

    The code assumes that there will be only two quantities in the bracket.
    Never : (12+53+17) ---> more than two qty.
    Never : (10) ---> only one qty
    but always : (46+23) ---> two qty.

    Also, since you don't mention how you want to name the generated sheet,
    I give the sheet name based on the Carton. No.

    Anyway, please have a look at the attachment.
    Attached Files Attached Files
    Last edited by karmapala; 06-04-2020 at 03:25 AM.

  3. #3
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    The Letter Size 'S,M,L,XL' aren't showing up a lot most of the time but they do show me I will upload an example of how they are like.

    Column H is the box qty is not always the correct which is why column P to calculate the coorect amount of box qty. Which is why I want to use column P instead of H

    Yes your understanding is correct.

    Thanks for your help I will do some testing.

  4. #4
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    The code works great thanks!

    But there's just one problem, can column C "PO" keep it as text when it's copy to the template? Becasuse at the moment when it's copy to the template it removed the first two zeros.

    Also can it includes an error check for the breadown and size? Let say if there are 4 sizes in total but there are only 3 breakdown it will show which line has the error? Becasue sometime the data is not alaways correct.

    Thanks

  5. #5
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    Quote Originally Posted by HXIO View Post
    column C "PO" keep it as text when it's copy to the template
    Sorry I didn't notice that.
    I've corrected the code.



    Also can it includes an error check for the breadown and size?
    Let say if there are 4 sizes in total but there are only 3 breakdown
    it will show which line has the error? Becasue sometime the data is not alaways correct.
    I have it like this :
    Make "CheckData" Sub to check if the size and the breakdown in each corresponding row is correct.
    If not correct, the corresponding row is highlighted with yellow.

    In "Test" Sub, that "CheckData" Sub is called in the beginning.
    If it find there is any row with a yellow color in the column N (breakdown),
    it will exit the sub after giving a message box "there is size/breakdown data which not correct".

    Assuming there is incorrect size/breakdown data (so the row has yellow color),
    after you correct either the size or the breakdown,
    you don't have to manually "no fill" to the cell in order the yellow color gone,
    because the next time you run again the "Test" Sub,
    if the "CheckData" Sub find not one incorrect data, it will "no fill" the column,
    since the "Test" Sub doesn't find any yellow row color in column N,
    then the "Test" Sub can continue it's job until the End Sub.

    Please have a look at the attachment.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    Thanks, I just realised that when the column M values is with "+" signs like this 4+6+8+16 it only works on the first time.

    For the other ones that appears afterward are all the same size. Maybe it did not rewrite the array for the dtSize? Because the quantity is correct but the sizes are wrong.

    Thanks

  7. #7
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    I just realised that when the column M values is with "+" signs like this 4+6+8+16 it only works on the first time.
    For the other ones that appears afterward are all the same size.
    Maybe it did not rewrite the array for the dtSize?
    Yes you are right, HXIO.
    Sorry my bad

    Please try to add :
    Please Login or Register  to view this content.
    after or before
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    I'd amended the code as you told me but it didn't fix the issues.

    Please advise

    Thanks

  9. #9
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    HXIO,

    When I test in my side, I've already add another line but then I forgot to tell you.
    Very sorry about that.

    Please add this line also :
    Please Login or Register  to view this content.
    before this line
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    This solved the problem!

    But I found out there are some other problems when I tested it with other data.

    I just realised if there are more than 3 numbers inbetween the brackets there're errors. For exmaple like this (12+23+89+100+89).

    Sorry I forgot to mention that there's this weird size call ONESIZE if there's such size apply in the size column it will all be call ONESIZE for all the lable generated.

    Updated - I uploaded a data set
    Thanks
    Attached Files Attached Files
    Last edited by HXIO; 06-08-2020 at 12:11 PM.

  11. #11
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    Quote Originally Posted by HXIO View Post
    @karmapala
    I just realised if there are more than 3 numbers inbetween the brackets there're errors.
    Yes of course it will throw an error .

    I've put a note in my post before :
    Quote Originally Posted by karmapala View Post
    The code assumes that there will be only two quantities in the bracket.
    Never : (12+53+17) ---> more than two qty.
    Never : (10) ---> only one qty
    but always : (46+23) ---> two qty.
    there's this weird size call ONESIZE if there's such size apply in the size column
    it will all be call ONESIZE for all the lable generated.
    Ok.. I will try it.
    My knowledge is still basic .

    I hope now it works with more than two qty in the bracket.
    Attached Files Attached Files
    Last edited by karmapala; 06-08-2020 at 04:39 PM.

  12. #12
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    Thanks it works now!

    Sorry I didn't see that message if I did I won't of told you my apologised.

    But the CheckData doesn't work because there are now more than 2 in between the brackets.

    Thanks

  13. #13
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Generate sheets from template by rows and copying values to the template

    Quote Originally Posted by HXIO View Post
    @karmapala
    But the CheckData doesn't work because there are now more than 2 in between the brackets.
    Hi HXIO,
    Sorry, yesterday already 4 am in my place - too sleepy to correct the CheckData Sub.
    Attach is with CheckData Sub
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Generate sheets from template by rows and copying values to the template

    @karmapala

    Thanks for the help!

    Everything works perfectly so far when I tested it with real data.

+ 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. Generate new workbook with sheets from template
    By bufoss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-12-2019, 03:17 AM
  2. [SOLVED] Copy 4 sheets from template and dynamically name, Save template and leave workin file open
    By Webbers in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2019, 02:39 PM
  3. [SOLVED] Generate new sheets from a list and use a template sheet only when generating.
    By Daril_Ghiroza in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-24-2015, 10:00 AM
  4. Replies: 1
    Last Post: 11-20-2015, 11:36 AM
  5. [SOLVED] Generate sheets with template based on datatable
    By kanonathena in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2013, 11:49 PM
  6. Template for query that can span multiple pages or sheets of a template if needed
    By anthallen_dps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2013, 11:52 AM
  7. How to populate values in Normal.dot template or any Template file
    By csekhar.apps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-11-2010, 01:03 AM

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