+ Reply to Thread
Results 1 to 18 of 18

Macro to extract and format data at piece level

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Macro to extract and format data at piece level

    Hello everyone,
    Hoping someone can help me out with a macro to do the below.
    I have a large set of data that I need to copy into another sheet but in a different format to the source data. At present, the piece data is split into rows by model but I would like the models to be split into columns so that each piece is only on one row like a pivot table would do. However, I can't use a pivot table as there is some data to the right that can't be in the values column.

    There are a lot more columns that I would need to copy across but the main issue is the split of pieces into rows rather than at model level in columns. Hope that makes sense!

    I have attached an example sheet with a before and after.
    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,454

    Re: Macro to extract and format data at piece level

    Is X, Y & Z the only model entries...
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    Hi
    No there are about 40 different ones, I just used the letters to simplify the data.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,454

    Re: Macro to extract and format data at piece level

    Give me a couple examples...

  5. #5
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    372

    Re: Macro to extract and format data at piece level

    Dear madmoo84,

    Please find the VBA code as I understand it
    Please Login or Register  to view this content.
    Attached Files Attached Files
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Mark Thread as Solved...

  6. #6
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    Just a few -
    L43A, L52A, S63A, P43P, T42A, T52A

  7. #7
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    372

    Re: Macro to extract and format data at piece level

    Quote Originally Posted by madmoo84 View Post
    Just a few -
    L43A, L52A, S63A, P43P, T42A, T52A
    what is this? i not able to understand please explain what is your requirement.

  8. #8
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    They are a few of the model numbers I would need to split out.
    Looking at the code, I could just repeat the following line and add each model in, changing the cell "E2", to F, G and so on?
    wsTarget.Range("E2").Value =

  9. #9
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    372

    Re: Macro to extract and format data at piece level

    S you need to add Try this
    Please Login or Register  to view this content.

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,454

    Re: Macro to extract and format data at piece level

    Output for testing in M2

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 11-01-2024 at 09:17 AM.

  11. #11
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    Thanks for the codes - it's not pulling through the number of pieces - they are all showing as 0
    I copied and pasted the code as is into the example sheet to test.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    29,968

    Re: Macro to extract and format data at piece level

    It suggests your data is not the same range as given in your sample file: code works fine for me.

    Post file that is not working.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  13. #13
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    It's the same file as the original one -
    Attached again with the code in
    Attached Files Attached Files

  14. #14
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,454

    Re: Macro to extract and format data at piece level

    Check out solution that solves in Post 10...

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    29,968

    Re: Macro to extract and format data at piece level

    Data is different format and all the data is zeros!

    And you are not using Sintek's code.

  16. #16
    Registered User
    Join Date
    01-16-2014
    Location
    Derby, England
    MS-Off Ver
    365
    Posts
    60

    Re: Macro to extract and format data at piece level

    The sheet with the zeros is the output when I ran the macro.

    Thanks - I tried the #10 code and that works

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,454

    Re: Macro to extract and format data at piece level

    Thanks - I tried the #10 code and that works
    ..........................
    THANKS.gif

  18. #18
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    372

    Re: Macro to extract and format data at piece level

    Dear madmoo84,

    sorry for late response. i update the VBA as your requirement and attached the excel sheet for your reference

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. [SOLVED] Extract data from last piece of sentence.
    By I need excel help in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2022, 05:45 PM
  2. Replies: 18
    Last Post: 06-06-2022, 07:24 AM
  3. Format the second level of multi-level category axis - clustered chart
    By mushkitoes in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-04-2018, 09:30 AM
  4. Macro to export each individual piece of data to new sheet
    By TWRB in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-05-2018, 08:02 PM
  5. How to display output from one locked data piece and one client-input data piece?
    By tnovak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2014, 12:48 PM
  6. Generate Query from Hyperlink and Extract a piece of data
    By justinvalle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-08-2009, 01:44 AM
  7. need to extract piece of string
    By als86 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2009, 09:40 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