+ Reply to Thread
Results 1 to 16 of 16

Copy data from one sheet to another (special criteria)

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2010 | 2013
    Posts
    43

    Copy data from one sheet to another (special criteria)

    Hi VBA Experts,

    Not new to this forum but very new with VBA.

    I have a report extracted from a system but the output format makes it difficult for data manipulation. If order to do that, I need to arrange data to a specific format.

    From the attached file:

    CopytoAnotherSheet.xlsx

    I like to copy data from Col A, B and C from Sheet 1 and represented in a nice order to Sheet2
    I have started writing out the steps but finding it hard to continue.

    Hope experts out there can offer some assistance or point me to right direction.

    Cheers

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Copy data from one sheet to another (special criteria)

    What is the significance of NSW? Is that supposed to be an abbreviation and do all companies have one in parentheses?


    Is sheet1 an actual export with just company names changed? The more accurate your data sample, the less exchanges it will take to get it right.
    For example: in some rows you have "Total for : ", in other you have "Total: for ", and yet a third variant "Total for :Butter" which leads me to believe this isn't the standardized export format. The place of the colon and spaces between words isn't consistent.
    Last edited by daffodil11; 04-18-2014 at 01:18 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    02-12-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2010 | 2013
    Posts
    43

    Re: Copy data from one sheet to another (special criteria)

    Hi there,

    Thanks for coming back. All the information I have provided is made up but format wise is 100%. Actual report is over 2800 lines

    1. There is not real significance with NSW. (FYI, NSW is a state in Australia) I have included as there are some companies with inclusion of symbols (e.g. " - " " () " ..etc)
    2. The export can vary each month. (e.g. Additional/deduction company name, additional/deduction product, additional/deduction product range) but format wise it will still be the same.
    3. The report is standard, but with inconsistent programming. What I can distinguish is:

    Product total ends with - "Total for :" (no space after colon) followed by product name
    Company total ends with - "Total : for " (space after after for) followed by company name

    I am currently attempting to do a loop ( Do..if.loop until Grande Total: ).. but a bit tricky.. so trying to find my way around it. Let me know if I am using the right technique. Was not expecting this to be that difficult. Any guidance would be great.

    Thanks

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Copy data from one sheet to another (special criteria)

    Hi Redcoal

    Will Company Name in Column B ALWAYS be in Bold Text? Will there EVER be ANY OTHER Bold Text in Column B other than Company Name?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    02-12-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2010 | 2013
    Posts
    43

    Re: Copy data from one sheet to another (special criteria)

    Hi Jaslake,

    Thanks for responding. Don't worry about the bold fonts, I put it there to make it stand out. Actual report, all cells are unbold.
    I have made quite a lot of progress with the macro but now slowly fine tuning it. Maybe is not the best method but appears to work with a few more steps.

    "daffodil11" - I did pick up a small mistake (one of the Total line) with my sample file but have since fixed.

    In the new file - Please refer to Sheet "Working"

    1. In Sheet Working - activate macro copy (This will extract a list in the same sheet, output Company, Product, Range, Sales values)
    2. still working on it.. copy Col I to L to Sheet "Extract" Col A to D. (Ideally when the entire code is complete, it wouldn't even need this step as I want step 1 to be in extract sheet)
    3. Select sheet "Extract", Col (C:D) only (i.e. Range & Sales), Go to --> Special --> Blanks --> Delete entire row (I tried recording a macro but it failed to work?) Manually is quite easy but automating it would be best.
    4. Select Col(C:C) (i.e. Range only) - Find word "Total" and delete rows --> Have a working codes for this, execute macro "delete_rows". However, to be safe I like to have a code to find "Total : for" and "Total for :". Can this be done in one code?
    5. Mission accomplished (First part of it for my purpose)

    I have created quite a few codes to make this happen, it doesn't look good I know. Is it normal to have individual codes everywhere? I guess, is still workable to start code 2 when code 1 is finished. Hope you can enlighten me with a better approach. Newbie with VBA but eager to learn.

    Here is the new file - CopytoAnotherSheet-1.xlsm

    Cheers

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Copy data from one sheet to another (special criteria)

    Hi Redcoal

    Show us what your raw data looks like with no modification...

+ 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. Replies: 1
    Last Post: 11-14-2013, 09:24 PM
  2. VBA script problem - Copy and Paste Special data from one sheet to another.
    By akarev in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 12:19 PM
  3. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM
  4. Replies: 4
    Last Post: 07-24-2012, 07:09 AM
  5. Replies: 5
    Last Post: 06-21-2012, 05:16 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