+ Reply to Thread
Results 1 to 23 of 23

Vba to manipulate table into new table

  1. #1
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Vba to manipulate table into new table

    Hi Experts,

    I need help to build a macro to convert the data in the 'Uber Spreadsheet' tab in to the 'Example of end results' tab.

    I have put a worked example with a description of each of the required rows and cells, a summary of which is below:

    For each row in the 'Uber Spreadsheet' there needs to be 3 rows added to a new tab and each row needs to have specific data as shown in the worked example.

    Hopefully someone can help here.

    Thanks,
    Sahil
    Attached Files Attached Files

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

    Re: Vba to manipulate table into new table

    Not sure if this is what you want.
    But maybe you want to try to run it if the result as you expected.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi karmapala,

    Thanks for this!

    One additional thing, apologies, my instructions were wrong. I need the values to sum up per day per store. So there will only ever be one set of the "SALES", "Delivery Fees", "Uber Services - NL 852 546722853 (e)" rows per store per day.

    Are you able to help with this?

    Thanks,
    Sahil

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

    Re: Vba to manipulate table into new table

    Too be honest, I'm not so sure if the code below gives the result as you expected.
    Anyway maybe you want to try to run it to see if it gives you the expected result

    Please Login or Register  to view this content.
    btw, I see that you don't define the mark if the store name has text "Guiseley" ....
    so I just define the mark for "Guiseley" in this line:
    Please Login or Register  to view this content.
    Last edited by karmapala; 09-15-2021 at 12:10 AM.

  5. #5
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi karmapala,

    This hasn't worked, see the attached spreadsheet for the result when you run this code.

    The debug highlights sumOU = Application.Sum(rg.SpecialCells(xlCellTypeVisible).Offset(0, 28)) as the error.

    Do you have any other ideas?

    Thanks,
    Sahil
    Attached Files Attached Files

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

    Re: Vba to manipulate table into new table

    Hi Sahil,
    That strange, because in my side, it runs till the end of sub.

    I downloaded your attachment,
    then run it without error as seen in the image below :
    2021-09-17_08-59-51.gif

  7. #7
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi karmapala,

    I am still getting the same issue, very strange.

    When I run the code it says 'No cells were found' so I think the filtering might be changing something. Can you send me the file you are using so I can see if anything has changed?

    Attachment 748058

    THanks,
    Sahil

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

    Re: Vba to manipulate table into new table

    Hi Sahil,

    Attached is the same file uploaded by you on post #5,
    but the sheet "result" already has data coming from running the macro.


    Did the error happen before writing any data to sheet "result" ?
    Or it has the chance to write some data, but in the middle of the loop it throw you the error ?

    Please try to debug the code line via F8.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi karmapala,

    Three line of incomplete data is written. Columns A to F is written but nothing else.

    Could this be an issue as we using different versions of excel?

    Sahil

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

    Re: Vba to manipulate table into new table

    Have you tried to debug (F8) it and watch the Locals Window while you debug it ?

    If the Local Windows is not there in VB Editor, show it via :
    View ---> Locals Window
    The Locals window will appear.

    Then put a stopper in this line :
    EXCEL_2021-09-24_15-28-30.png

    Then debug it by pressing F8 one at a time,
    and see what happen in the Locals window.

    Once the yellow pass the "sumOU = ..." line,
    in the Locals window you should see sumOU 5.04
    If not, then there is something wrong.

    Assumed that you see sumOU 5.04 in the Locals window,
    continue press F8...

    Once the yellow pass the "oStart.Offset(0, 7).Value = ..."
    On the sheet you should see 5.04 in cell H3.

    Continue to do like that (press F8 slowly one at a time then watch the Locals window),
    until the end of the sub.

    Once you noticed the Locals window doesn't give any result
    (once the yellow past the sumOU, sumIncS, sumIncU, sumVat etc)
    and/or it doesn't write the result to the sheet
    (once the yellow past the "oStart.Offset(...,...).value= ..."
    Please write down what is the current el value in the Locals window
    which doesn't give any result value to the sum and/or to the writing of the result to the sheet.

    Could this be an issue as we using different versions of excel?
    I don't know that.
    In my side the code runs till the end without error,
    where the result as you see in the attached workbook on post #8.

  11. #11
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi karmapala,

    When I run through the code the sumOU is 'Empty' in the local window as shown in the screenshot at the "sumOU = Application.Sum...." line of code.
    Attachment 749270

    Then when I press F8 again, the data in the local window disappears and I get the same "No cells were found" error. Screenshot below.Attachment 749271

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

    Re: Vba to manipulate table into new table

    Sahil,

    Please try to add above the "sumOU =" line :
    Please Login or Register  to view this content.
    So it become like this :
    Please Login or Register  to view this content.
    Put the red stopper at that addition line, like below image:
    EXCEL_2021-09-27_23-12-20.png

    Before running the code, please make sure that sheet Uber Spreadsheet is being activated.
    Then run the code, once it stop at the red dot, press F8 in your keyboard computer...
    then see if the addition code line is causing cell AG2 (with a value 5.04) becomes selected.
    In my side, it did select cell AG2.

    Please let me know how is the result after you've tried it.
    I'm sorry for the inconvenience.

    ----

    Although I'm curious why in your side it doesn't give you the expected result,
    maybe you can just skip my instruction above and just try the workbook I attached in this post.
    It use different code (before I use filter - now I use sumifs) I hope this time it works in your side.
    Attached Files Attached Files
    Last edited by karmapala; 09-27-2021 at 12:57 PM.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Vba to manipulate table into new table

    Sahil1991SP,
    Try the attached and see if it is how you wanted.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi jindon,

    Apologies I missed the notification for your reply.

    Your code almost works perfectly apart from one point:

    - In the 'myresults' tab in the 'Marks' column the labelling system isn't working as expected. I see 'CC', 'CG' and 'CH' which are not the correct store lettering. Each store has a specific letter (see below) that needs to be added to the 'Marks' column. This letter is based on column C in the 'Uber Spreadsheet' tab. There are store names in brackets in column C and if the store is named then the corresponding letter needs to be shown in the 'Marks' column in the 'myresult' tab:

    Greengates = r
    Shipley = l
    Crossgates = xg
    Starbeck = st
    Dewsbury =db
    Hunslet =hl

    Are you able to help me with that?

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Vba to manipulate table into new table

    Change to
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Thank you so much jindon, that worked.

    Apolgies I didn't spot another issue previously. If there are multiple rows in the 'Uber Spreadsheet' tab' for the same store (column C) on the same day (column E) I need the values to be summed on the 'myresults' tab so there is only one set of the 3 rows (sales, delivery fee, uber services...) for each store-date combination.

    Are you able to add that for me?

    Thanks,
    Sahil
    Last edited by Sahil1991SP; 11-04-2021 at 11:13 AM.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Vba to manipulate table into new table

    If you want to summarize the data, I need to see your desired result.

  18. #18
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi jindon,

    Apologies for the late reply, I didn't get a notification for your response.

    Please see attached an example of what the final output should look like, see the 'Example of output' tab. I have colour coded the days from the output of the current code to show how these need to change, I hope that makes sense.

    Thanks,
    Sahil
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Vba to manipulate table into new table

    See if this is how you wanted,

    Figures are different from yours.
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi jindon,

    The latest change seems to have created a few errors in the calculations.

    I have attached another spreadsheet with what the values should be and added comments for which cells they refer to in the data tab.
    I have also noticed that there are several date-store combinations missing and I have added the list of these in the 'MMTemplate' tab in column N. I think because some date-store combinations are missing, the figures which should have been associated with them are being included in the wrong date-store.

    Please let me know if you find a way to resolve this.

    Thanks,
    Sahil
    Attached Files Attached Files

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Vba to manipulate table into new table

    Change 5 to 6 in 2nd loop in GetSummarize,
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  22. #22
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Vba to manipulate table into new table

    Just for the fun of it...My take on this one...Making use of Template Sheet as helper...
    Lending from jindon...
    I get same results...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    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 star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  23. #23
    Registered User
    Join Date
    11-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    Re: Vba to manipulate table into new table

    Hi jindon, sintek,

    Thanks for your inputs, I managed to get it to work!

    Thanks,
    Sahil

+ 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] VBA to manipulate pivot table in to 'normal' table for account software upload
    By Sahil1991SP in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-03-2021, 06:35 AM
  2. Manipulate table of data into a different table
    By dancing-shadow in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-09-2014, 07:20 AM
  3. [SOLVED] how can I make a button that manipulate table in two ways?
    By netanel99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2013, 08:24 AM
  4. Manipulate data table below the pivot chart
    By Malette in forum Excel General
    Replies: 7
    Last Post: 03-28-2012, 11:45 AM
  5. Manipulate and arrange table data into summary list
    By DavidSpackman in forum Excel General
    Replies: 2
    Last Post: 07-28-2010, 12:57 AM
  6. [SOLVED] Can't manipulate pivot table
    By Grrffin in forum Excel General
    Replies: 1
    Last Post: 11-17-2005, 01:15 AM
  7. How do I manipulate pivot table report to include percentage of?
    By KRUEMJ-Needs some help in forum Excel General
    Replies: 2
    Last Post: 01-30-2005, 10:06 PM

Tags for this Thread

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