+ Reply to Thread
Results 1 to 7 of 7

repeat data on (odd/even) row

  1. #1
    Registered User
    Join Date
    05-06-2011
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    repeat data on (odd/even) row

    hi.

    i need to create a macro function to run a repeat cell data that pulling from a sheet in the same excel file.
    attached sample

    basically what i need to do is:

    write a macro:

    insert a new sheet and name it as "upload"

    on the "upload" sheet:

    A1 to be "ASN Header"
    A2 to be "ASN Shipment"
    A3 to be "ASN order"
    B1 - default and always to be as " 056481716"
    B2, C1 & C2 - I will manually input the data
    D1 - default and always to be as "Zoe"

    B3 = ASN!A2

    here comes the tricky part from below:

    on Column B (on every even cell) from:
    A4= shown as "ASN Item"
    B4 = ASN!G2 = as: 1038, but it needed to add one 0 in the front so it appears as 01038 in this sample file

    same on Column B (but, on every odd cell) from:
    A5 = shown as "ASN CASE CONTAINER"
    B5 = ASN!I2 = as: 12 in this sample file

    on Column C (on every odd cell) from:
    C5 = ASN!J2 = as: 104004437 in this sample file

    under this formula method, repeat down until it reach Total

    so, the theory is kind of like repeat alternately in even row/ odd row:

    on column A, every even row (starting from A4) = A4 shown as: "ASN Item", repeat A6 "ASN Item", repeat A8 "ASN Item".... continue and stop until it reaches Total shown on Column A

    on column A, every odd row (starting from A5) = A5 shown as: "ASN CASE Container", repeat A7 "ASN CASE Container", repeat A9 "ASN Item".... continue and stop until it reaches Total shown on Column A

    in this sample file, Total is on cell: A1379

    moving to Column B

    on column B, every even row (starting from B4) B4= ASN!G2, repeat B6 = ASN!G3, repeat B8 = ASN!G4 ... continue until and stop until it reaches Total on Col.A
    on column B, every odd row (starting from B5) B5= ASN!I2, repeat B7 = ASN!I3, repeat B9 = ASN!I4 ... continue until and stop until it reaches Total on Col.A
    on column C, every odd row (starting from C5) C5= ASN!J2, repeat C7 = ASN!J3, repeat C9 = ASN!J4... continue and stoop until it reaches Total on Co.lA

    stop until it reach Total (in this sample is A1379)

    I hope it makes sense, let me know if anything is confused.

    any help is appreciated !
    Attached Files Attached Files
    Last edited by Baboo; 11-07-2012 at 04:01 PM. Reason: solved

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: repeat data on (odd/even) row

    Maybe this will work for you

    Please Login or Register  to view this content.
    Last edited by mike7952; 11-06-2012 at 07:59 PM.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    05-06-2011
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: repeat data on (odd/even) row

    hi Mike,

    I got a run time error.

    With Worksheets(shUpload)

    what could be wrong ?

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: repeat data on (odd/even) row

    Is there a sheet named ASN upload in your workbook?
    If not change at the top of code
    Please Login or Register  to view this content.
    See attatched file. Click button to run macro. Then look at sheet ASN upload

    sample file.xlsm

  5. #5
    Registered User
    Join Date
    05-06-2011
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: repeat data on (odd/even) row

    thanks Mike. this work like a magic.
    however, I realizedASN ITEM lines only need to be appeared once, then repeat ASN CASE CONTAINER lines as many times as needed.
    it should look like below.

    can you amend the marco again ?

    ASN ITEM 01038
    ASN CASE CONTAINER 12 104004437
    ASN CASE CONTAINER 12 104004565
    ASN CASE CONTAINER 12 104004566
    ASN ITEM 01041
    ASN CASE CONTAINER 12 104004440
    ASN CASE CONTAINER 12 104004737
    ASN CASE CONTAINER 12 104004738

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: repeat data on (odd/even) row

    Give this a try

    Please Login or Register  to view this content.
    Last edited by mike7952; 11-07-2012 at 03:01 PM.

  7. #7
    Registered User
    Join Date
    05-06-2011
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: repeat data on (odd/even) row

    great, thanks a million!! it works!

+ Reply to 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