+ Reply to Thread
Results 1 to 41 of 41

VBA code amendment required for updated workbook format

  1. #1
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    VBA code amendment required for updated workbook format

    Hello

    My workbook has old code which did achieved what I still want to achieve however the format of the workbook/sheets has now expanded/changed so I am looking for the code to be amended (or new code if required).

    The aim is to pull data from 8 sheets (W1>8) and show in a new sheet (manpower import) in the relevant order and columns. The order should be in date and in earliest time (start).

    In sheet (manpower import) I have put an example of the desired result (columns L-Q), which should appear in columns B to G. The import button is existing from the old solution.

    If any sheets need to be unlocked the pw for this example doc is open.

    Help would be very very appreciated, as I unfortunately just don't understand code!!

    I have deleted other sheets in the interest of size for upload but the workbook will contain more sheets if that makes any difference-however I can keep the sheet names as they are.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA code amendment required for updated workbook format


    Quote Originally Posted by harea View Post
    The order should be in date and in earliest time (start).
    Hello,

    so should be easier with column ORDER as the first column and do you really need this useless column ?!…


    Quote Originally Posted by harea View Post
    The aim is to pull data from 8 sheets (W1>8)
    As W7 and W8 are missing so you must rename the worksheets in order to work with consistant names at least !


    Rather to decrypt, decypher your need - your result worksheet is empty ‼ - that may help
    if you attach the exact expected result according to your initial post attachment …
    Last edited by Marc L; 04-22-2023 at 06:16 AM.

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

    Re: VBA code amendment required for updated workbook format

    Small enough data set...Basic loops...
    Changed 7 & 8 to W7 & W8
    Not sure where you get your 20 entries...I only get 8
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 04-23-2023 at 07:26 AM. Reason: Added File
    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!!!

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA code amendment required for updated workbook format

    Hello. About the attached model I suggest you:

    a) Replace the 'MANPOWER IMPORT' sheet of your original model and replace it with the one attached here since the table already has the appropriate formats and the macro is in the sheet itself.

    b) The data summary is obtained from the sheets between 'FRONT PAGE' and 'MANPOWER IMPORT'. So you don't need to change the names of the sheets and they can have any name (they don't need to start with "W").

    c) Finally, I would like to point out that what I attached is 4 times smaller than what you uploaded to the Forum. What's the big difference?... I removed the "graphical" objects.
    I suggest you try to reconvert your images into less "giant" objects.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  5. #5
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Hi Marc L

    Thank you for taking the time to look into this.

    What useless column sorry?
    I can't rename sheets 7 and 8 because of a formula which this change would take overt the excel formula character limit.
    I have attached the expected result in a example table (columns L-Q)?

  6. #6
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Hi Sintek

    Thank you for looking at this!

    I can't rename sheets 7 and 8 because of a formula which this change would take overt the excel formula character limit.
    The 20 results are correct?

  7. #7
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Hi beyond Excel

    Thank you for your help!!

    I will look in to this now and reply!!

    Sorry, but what are graphical objects? and I don't understand *reconvert your images into less "giant" objects* ? Sorry for being dumb!! I assume you are referring to images in cells D3 in W1>8 sheets?

    Thanks

    E

  8. #8
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by beyond Excel View Post
    Hello. About the attached model I suggest you:

    a) Replace the 'MANPOWER IMPORT' sheet of your original model and replace it with the one attached here since the table already has the appropriate formats and the macro is in the sheet itself.

    b) The data summary is obtained from the sheets between 'FRONT PAGE' and 'MANPOWER IMPORT'. So you don't need to change the names of the sheets and they can have any name (they don't need to start with "W").

    c) Finally, I would like to point out that what I attached is 4 times smaller than what you uploaded to the Forum. What's the big difference?... I removed the "graphical" objects.
    I suggest you try to reconvert your images into less "giant" objects.

    Please Login or Register  to view this content.
    Hi beyond Excel

    When I do this it says;

    "Compile error:

    Sub or Function not defined"

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

    Re: VBA code amendment required for updated workbook format

    The 20 results are correct?
    You only have 8 entries in all the sheets...Please explain by referencing where these 20 results come from and how they were calculated...?

    Not to worry...I get it...No of entries depends on staff allocation...

    Please Login or Register  to view this content.
    Last edited by sintek; 04-23-2023 at 08:52 AM.

  10. #10
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Hi Sintek

    Thank you so much!

    When I put this code in to the actual workbook it shows a run time error? If i click on * dubug * it highlights * .Range("B3").Resize(x, 6).Value = Temp *?

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

    Re: VBA code amendment required for updated workbook format

    It works for sample file...Right...
    If your actual book is same setup as sample then it should work...
    What does the error say...

  12. #12
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Ignore--this is my fault!!! There was no data for it to pull from, but after entering data it works perfectly - I just need to assign it it a button but it works from the developer run button 🥳

    Thank you so so much!! and thank you everyone else for your time and efforts also - so very much appreciated!!

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

    Re: VBA code amendment required for updated workbook format

    ..............................
    THANKS.gif

  14. #14
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    One question on it; when it runs it unlocks the sheets (which I assume is to allow it to run), is it possible to re-lock them?

    It also is ignoring sheets 7 and 8?
    Last edited by harea; 04-23-2023 at 08:49 AM.

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

    Re: VBA code amendment required for updated workbook format

    is it possible to re-lock them?
    See red snippet added above...
    It also is ignoring sheets 7 and 8?
    Not in sample file...

  16. #16
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    See red snippet added above...

    Not in sample file...
    Hi Sintek

    Thanks I will add that in

    They are in sample file? there should be 8 sheets in total (W1,W2,W3,W4,W5,W6,7,8) Sheets 7 and 8 aren't called W7 and W8 due to a different formula which these characters would take it over the character limit

    Also; on sheet W6 it seems to be doubling the values but it doesn't happen on any of the other sheets that I can see?

    Thanks

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

    Re: VBA code amendment required for updated workbook format

    They are in sample file?
    I know...What I am saying is...It is not ignoring it in the sample file...
    It works as it should, even with adding extra entries into sheet 7 & 8
    Perhaps you should upload another sample file with more entries and show expected result...
    Last edited by sintek; 04-23-2023 at 09:28 AM.

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

    Re: VBA code amendment required for updated workbook format

    Have "loadshedding" for the next 2 - 4 hours so can only check in again later...

  19. #19
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by harea View Post
    Sorry, but what are graphical objects? and I don't understand *reconvert your images into less "giant" objects* ? Sorry for being dumb!! I assume you are referring to images in cells D3 in W1>8 sheets?
    Exactly: that's right.

  20. #20
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by harea View Post
    Hi beyond Excel
    When I do this it says;
    "Compile error:
    Sub or Function not defined"
    Let's go by parts:
    - The workbook that I showed you in post #4: Does it work correctly?...

  21. #21
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by beyond Excel View Post
    Let's go by parts:
    - The workbook that I showed you in post #4: Does it work correctly?...
    Hi beyond Excel.

    No unfortunatly not. It says

    "Compile error:

    Sub or Function not defined"

    and then the debugger highlights; Sub Macro8()

  22. #22
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    I know...What I am saying is...It is not ignoring it in the sample file...
    It works as it should, even with adding extra entries into sheet 7 & 8
    Perhaps you should upload another sample file with more entries and show expected result...
    Hi Sintek

    I have tried to put a screen recording in to a word doc to allow you to see current process - let me know if this works? (somewhat of a challenge trying to upload a video here)

    Thanks

    E
    Attached Files Attached Files

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

    Re: VBA code amendment required for updated workbook format

    No...See post 17....As per sample file...all works as it should...Upload new showing issue...Can only be that your actual file does not represent as your sample file shows...

  24. #24
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by harea View Post
    Hi beyond Excel.
    No unfortunatly not. It says
    "Compile error:
    Sub or Function not defined"
    and then the debugger highlights; Sub Macro8()
    Remember I told you to replace the 'MANPOWER IMPORT' sheet from your actual workbook with the 'MANPOWER IMPORT' sheet from the workbook I showed you in post #4: it looks like you didn't.

  25. #25
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by beyond Excel View Post
    Remember I told you to replace the 'MANPOWER IMPORT' sheet from your actual workbook with the 'MANPOWER IMPORT' sheet from the workbook I showed you in post #4: it looks like you didn't.
    Hi Beyond Excel

    I did this by copying the sheet across workbooks and deleting the original sheet? Is this what you mean? If yes, then it shows the compile error

  26. #26
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    No...See post 17....As per sample file...all works as it should...Upload new showing issue...Can only be that your actual file does not represent as your sample file shows...
    Hi Sintek

    Apologies, you are right it does work in the sample file however sheets 7 and 8 have been renamed to W7 and W8 which I can't do due to a character limit in a other excel formula. I assume it is the naming which is stopping this working here?

    Thanks
    E

  27. #27
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by harea View Post
    I have tried to put a screen recording in to a word doc to allow you to see current process: let me know if this works? (somewhat of a challenge trying to upload a video here)
    Thanks, E
    The image you show in post #22 indicates that there is a sheet called 'QUOTE' between 'FRONT PAGE' and 'W1'.
    That sheet: Does it have the same structure as W1, W2, etc or not?...

    Remember that in my help the sheets between 'FRONT PAGE' and 'MANPOWER IMPORT' are processed. If that 'QUOTE' sheet does not have the same structure, it is you who is generating the error.

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

    Re: VBA code amendment required for updated workbook format

    See post 17 & 23...Like I said...If actual file is same setup as sample file then the code as you already commented as working...should work...
    I have used your original file without changing sheet names, inserted more time slots in the other sheets W1-W6, 7, & 8 and all works as it should with code supplied in Post 9...
    Gonna go around in circles...

  29. #29
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by beyond Excel View Post
    The image you show in post #22 indicates that there is a sheet called 'QUOTE' between 'FRONT PAGE' and 'W1'.
    That sheet: Does it have the same structure as W1, W2, etc or not?...

    Remember that in my help the sheets between 'FRONT PAGE' and 'MANPOWER IMPORT' are processed. If that 'QUOTE' sheet does not have the same structure, it is you who is generating the error.
    Hi Beyond Excel

    I have no doubt it is me, but i believe I have followed the instructions? Please see attached screen recording

    Thanks

    E
    Attached Files Attached Files

  30. #30
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    See post 17 & 23...Like I said...If actual file is same setup as sample file then the code as you already commented as working...should work...
    I have used your original file without changing sheet names, inserted more time slots in the other sheets W1-W6, 7, & 8 and all works as it should with code supplied in Post 9...
    Gonna go around in circles...
    Hi Sintek

    I do apologise but I don't know where I am going wrong? Sheets W1>8 are identical in setup. Using your code Sheets W1>W4 seem to work perfectly, W5&W6 duplicate results, 7 and 8 result in an error? I have tried to show this in the attached screen recording. Thank you for being so patient!!
    Attached Files Attached Files

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

    Re: VBA code amendment required for updated workbook format

    why not just upload the file...

  32. #32
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    I'd love to but file size and upload limits...

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

    Re: VBA code amendment required for updated workbook format

    Then...Upload another sample file with more entries...and show expected outcome...If the code works to give same results, then there is something wrong with main file...Cannot help without this...

    As I said...all works as it should with your sample file initially attached...

  34. #34
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Helloo

    I have managed to get it down to size by removing 13sheets which sit AFTER sheet "Manpower Import". I have also removed some images (from D3 on sheets W1>8)but I assume that won't affect any code.

    I can swap front page / quote page sheet positions if required.

    Thank you...I know my level of understanding is very unhelpful!!

    Best

    E
    Attached Files Attached Files

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

    Re: VBA code amendment required for updated workbook format

    This does not help at all...You have uploaded a sample file with no entries in any of the sheets and have shown no expected outcome???

  36. #36
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    This does not help at all...You have uploaded a sample file with no entries in any of the sheets and have shown no expected outcome???
    Apologies...I have now included an example table of outcomes in sheet manpower import using data from Sheets W1, W5 and 7 out of the 8 sheets in total (W1>8).

    Is this sufficient?

    Thanks

    E
    Attached Files Attached Files

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

    Re: VBA code amendment required for updated workbook format

    using data from Sheets W1, W5 and 7
    Harea...You mentioned previously above that the code only works for some sheets and errors with others...
    So ideally...If you are wanting us to solve this...Then surely you need to do a bit of work...
    So...upload a sample file with multiple entries in ALL the sheets W1-W6 & 7 & 8 and show expected outcome...This way we are able to ascertain what the issue is...If any...
    Understand?

  38. #38
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    Harea...You mentioned previously above that the code only works for some sheets and errors with others...
    So ideally...If you are wanting us to solve this...Then surely you need to do a bit of work...
    So...upload a sample file with multiple entries in ALL the sheets W1-W6 & 7 & 8 and show expected outcome...This way we are able to ascertain what the issue is...If any...
    Understand?
    Hi Sintek

    Please find attached. Hope this is what you need?

    Thanks

    E
    Attached Files Attached Files

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

    Re: VBA code amendment required for updated workbook format

    Oh my word harea...My bad...
    Did not change the sheet no to STRING...Would have picked it up if data existed...
    This gives exact same output...
    Attached Files Attached Files
    Last edited by sintek; 04-27-2023 at 06:50 AM.

  40. #40
    Registered User
    Join Date
    03-10-2022
    Location
    england
    MS-Off Ver
    365 on mac
    Posts
    35

    Re: VBA code amendment required for updated workbook format

    Quote Originally Posted by sintek View Post
    Oh my word harea...My bad...
    Did not change the sheet no to STRING...Would have picked it up if data existed...
    This gives exact same output...
    I don't know what this means but thank you so so much!!! all seems to be working perfectly!!!

    Is there anything I need to know? (not change sheet order etc?)

    I am so appreciative of your patience and efforts!!!

    Thanks you

    E

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

    Re: VBA code amendment required for updated workbook format

    Glad you got it sorted...All good...

+ 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 code for copy data to another sheet, do amendment in that code
    By keshavtale in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-07-2021, 10:30 AM
  2. Amendment in code required to populate new sheets with colour
    By User3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2017, 02:35 AM
  3. [SOLVED] count frequency - formula amendment required
    By Nubian in forum Excel General
    Replies: 10
    Last Post: 12-18-2015, 12:22 PM
  4. Button Required to Send Updated/Historical Data to Appropriate Sheets in Workbook
    By swordswinger710 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-23-2011, 03:38 PM
  5. Macro Amendment Required For Calculation Code
    By JimmiOO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2010, 08:16 AM
  6. Replies: 3
    Last Post: 11-05-2009, 10:17 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