+ Reply to Thread
Results 1 to 160 of 160

File Optimization with Macro

  1. #1
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    File Optimization with Macro

    Hello guys,
    I'm getting crazy with this file.
    in the last sheet named ANALISI in the column E ... I have calculed the avarage using this formula =MEDIA(SE(A:A=A2;D:D)) after that I copied and pasted only the value because everything got slower.

    As you can see in the file it has calculed the avarage also when it wasn't necessary... how can I solve it?
    Later on , I have to create a new macro so I can also use VBA formulas...

    I should have also to hide line with the text NON CONSIDERARE.

    Hope someone can help me ..

    Thanks in advance,
    your help would be very appreciated.
    Attached Files Attached Files
    Last edited by Veronique Dubois; 08-03-2023 at 11:21 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    I hope the formula is clear to you, but the reason it's slow is because you use A:A as range, this is over 1 million rows !!!
    You should try $A$2:$A$1400
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Post Re: File Optimization with Macro

    Thanks for the answer, I m going to try .. is it possible to change formula from $A$2:$A$1400 into $A$2:$A$(Last cell in the column) ?

    Otherwise do you know another method smarter to do it? I try to explain what I need in that fields ... I have to check if in the column A there are two or more equal codes, get the price in column D and make the average of them.

    further..do you have any suggestion about hiding line with the text NON CONSIDERARE?

    I'm so sad
    Last edited by Veronique Dubois; 08-04-2023 at 02:32 AM.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    I'll see what I can do and let you know, you can always hide the columns you do not want to see

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    In English, the formula would be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    My formula for column E

    Please Login or Register  to view this content.
    in Italian:
    Please Login or Register  to view this content.
    Thelast row part follows but this is a starter, TMS also works

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Again, in English, all in one go:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah: why in Italian?

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Updated file
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Thanks a lot for your support !
    I cannot explain how much I appreciate it.

    however in the original file it doesn't work... probably is my fault! appear ESPANSIONE traslated expansion
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Quote Originally Posted by TMS View Post
    @Keebellah: why in Italian?
    I guess the assumption from the file name is that the OP is an Italian, even though they appear to be in France and have a very 'French' user name.

    "ESPANSIONE" is also an Italian word. Maybe their locale is also Italian?

    https://support.microsoft.com/it-it/...2-ef9cc9ad4023
    Last edited by AliGW; 08-04-2023 at 04:29 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  12. #12
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello Ali,

    Yes I was born in France but I'm in Italy since 6 months ago

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Veuillez changer la location dans votre profil: "Italy" suffira. Merci.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    That looks like it will be a #SPILL error in English. Delete everything in the column before entering the formula.

    However, if that is a Structured Table, it won't work.

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Thanks for the rep.

  16. #16
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I'm blocked again.
    I have this two issues:

    1- in the sheet named analisi when it's empty, during the macro registration, I have to concatenate fields in the RDO sheets [ =CONCAT(RDO!A2;RDO!F2)] and scroll it down till the last field in the RDO...honestly I don't know how to do it automatically,
    because if I scroll it till a fixed cell it makes problem with average formula in the column E

    2- the average formula in column E start to be always the same value ...I don't know why...probably due to the mistake in the "Point 1"

    Please check the attached file.

    Thanks
    Attached Files Attached Files

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Maybe ...

    D2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    copied down

    E2 (only):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Sorry probably I wasn't very clear:

    when I generate sheet named ANALISI in the column A I have to concatenate column A and F of the sheet RDO and I must do it for every value in the column A of RDO....
    But double-clicking in the right corner of the A2 cell it doesn't work.. is there a formula for this?

    wronging this part also the column E of ANALISI Sheet ..doesn't work.

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Clear everything on the ANALISI worksheet apart from the headings. Then:

    A2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    B2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    C2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    D2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    E2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  20. #20
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Updated sample file attached.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I think that A - B - C - D are correct , however E seems to be wrong.

    column E should be: if I find same values in column A then make the average of their value in column D... if you see your file in column E there are same value of D instead of the average.

    Thanks for the patience

  22. #22
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    As far as I can see, there is only one of each code, hence the values are the same. However, the problem is that the INDEX/MATCH in column D will return the first matching value for any code. So, , if there ARE more than one entries for a code, it will return the first value found for them all.

    Need to come back to this later as I'm going out for the rest of the day.

  23. #23
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    yes thanks no problem !

  24. #24
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Ok, given that columns A:C are simply row by row concatenations, there's no point trying to use INDEX/MATCH to return column D ... it won't work.

    Anyway, simple solution ... a "straight" link:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See the updated workbook. Note that the code in the third row of RDO has been copied from the second row to demonstrate the formulae.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello master,
    it seems to be a good solution THANKS !
    unfortunately during the Macro registration appears this error , do you know the reason?
    Attached Images Attached Images

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    You probably need to translate the formula into Italian:

    =LET(lr;CONTA.VALORI(RDO!A:A);PERRIGA(B2:INDICE(B:B;lr);LAMBDA(x;INDICE(RDO!Y:Y;RIF.RIGA(x)))))

  27. #27
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I changed the code in english using " , " in place of " ; " ... now works in the macro but generate a mistake in excel sheet
    Attached Images Attached Images
    Last edited by Veronique Dubois; 08-07-2023 at 03:09 AM.

  28. #28
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  29. #29
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Once solved I close the thread

  30. #30
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    The formulae in the latest screenshot are all in English. They need to be in Italian. It's not just a case of changing commas to semi-colons. You've gone the wrong way, anyway: change English into Italian.

    PS The final formula is a mixture of Italian and English. You need to be consistent throughout.
    Last edited by AliGW; 08-07-2023 at 03:40 AM.

  31. #31
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    This is the code in English

    Please Login or Register  to view this content.
    Note that it is Formula2 NOT Formula2R1C1

    Try replacing just the formulae in the code with the Italian versions from the workbook that I uploaded.

  32. #32
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    This compares Median with Average in columns E and F. Which do you need?

    Please Login or Register  to view this content.

    Do you really need VBA? These formulae all auto-adjust. You only need to drop them in once.

  33. #33
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Now it works
    Yes I'd like to do a macro...
    do you know how to autofill till the last cell? I mean if I launch the macro next time and I have more or maybe less than 1400 rows how can I auto adjust them?
    (please see the pic)
    Attached Images Attached Images

  34. #34
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Please don't upload pictures, upload the working workbook/code.

    Yes, I know how to do it. You are asking for a formula that you haven't used before?

  35. #35
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I need a formula for autofilling without a limited range...for ex instead of:

    Selection.autofill destination:=range("J2:J1400") should be Selection.autofill destination:=range("J2:last cell necessary"

  36. #36
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    it doesn't work yet... I am getting sad I want to cry..
    columns D and E are not working they don't take the correct value in column D and the E consequently doesn't make the avarage maybe bcs for calculate columns F,G,H,I,J I had change columns A,B,C copy and paste as value..?

    please see the attached file, unfortunately I have to delete some double codes due to the max dimension for the attachment
    Attached Files Attached Files
    Last edited by Veronique Dubois; 08-07-2023 at 06:16 AM.

  37. #37
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I don't understand this:

    columns D and E are not working they don't take the correct value in column D and the E consequently doesn't make the avarage maybe bcs for calculate columns F,G,H,I,J I had change columns A,B,C copy and paste as value..?
    If it is not giving you the values you want, what should they be? As I explained before, you hav unique entries in RDO so you won't see any changes between column D and E. I would need to see more data where there are multiple entries for some codes.

    As I explained before, if you DO have more than one entry for a specific code, then INDEX/MATCH will always return the matching value for the FIRST entry. Not a problem with the sample data because there is only one entry for each code.
    Last edited by TMS; 08-07-2023 at 06:38 AM.

  38. #38
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Please check for ex rows 70-72 they are the same code (3B-017168) bought two times one from supplier FI00009079 and one from FI00003257 in the column D it takes the correct value 48 and 23 (price in RDO file colum Y) but in column E it doesn't do the average 35,5 ...
    ....furthermore I was now thinking that for calculating in the next formulas this average should appear just one time so difficult :/
    Last edited by Veronique Dubois; 08-07-2023 at 07:36 AM.

  39. #39
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    70 3B-017168FI0000907944898
    71 3B-017169FI0000907944898
    72 3B-017168FI0000325744898


    I think your tears may be my fault, so please forgive me. In your OP you quoted the formula =MEDIA(SE(A:A=A2;D:D))

    I mistranslated the function MEDIA straight into English as MEDIAN. It should, I think, have been AVERAGE. I have mentioned the difference a couple of times because it didn't seem right to me that you would want/need the Median value, but stranger things have happened.

    So, maybe this gives you what you want

    Please Login or Register  to view this content.

    Again, please not that INDEX/MATCH may not return the value that you expect.

  40. #40
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    In your original post, you used the formula: =MEDIA(SE(A:A=A2;D:D)) which I now know translates to =AVERAGE(IF(A:A=A2,D:D))

    That is saying, average column D if column A equals A2. Copied down, that would become A3, A4, A5, etc.

    However, you are using CONCAT to build a reference code in column A and they are all unique.

  41. #41
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Post Re: File Optimization with Macro

    it doesn't work again..I try to be clearer

    Sheet ANALISI - Column A for example:

    70 3B-017168FI0000907944898

    code: 3B-017168
    Supplier: FI00009079
    Date: 44898

    72 3B-017168FI0000325744898

    Code: 3B-017168
    Supplier: FI00003257
    Date: 44898


    if I find the same code (in the column A) in the same date (last numbers in the each cells of column A) BUT from different suppliers (FI part) then I need the average of their price indicated in column D .


    I believe you !! you the lonely one can solve this :D
    Last edited by Veronique Dubois; 08-07-2023 at 09:34 AM.

  42. #42
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I suspect that, if your desire and intent is to total and average by Codice Prodotto (Product Code), your analysis is not going to give you that.

    Perhaps we are starting from the wrong place? As I've heard it said, "if I wanted to go there, I wouldn't start from here".

  43. #43
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Similarly, If you want to total and average by Product and Date, your analysis doesn't do that.

    On Analisi, column A is a concatenation of RDO columns A and F. On RDO, column A is a concatenation of columns L and B. Hence, as you know, this is a concatenation of columns L, B and F. You don't have a column that is just Product and Date (L and F) and that is what you need for your analysis.

    I can do that but do you have a preference as to where it goes? And am I correct in my supposition that that is what you want?

  44. #44
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I don't know... I just want to die :')

    every code has been asked to more suppliers in the same date and any supplier offers a price (column Y RDO Sheet).. I need the average of these prices.
    In this way calculating the total expense minus the average of the offers I can estimate a saving.
    this what I need and only concatenating and matching them I thought to find these values
    Last edited by Veronique Dubois; 08-07-2023 at 09:50 AM.

  45. #45
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Leave it with me. I think I know what is needed now and I will try and produce something later.

  46. #46
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    yes ...I m so sorry to bother you
    I m also bad in English and it's difficult to explain it.
    Last edited by Veronique Dubois; 08-07-2023 at 10:10 AM.

  47. #47
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Pretty sure your English is way better than my French (not great) or Italian (non existent) Worry not, I'm sure we'll get there

  48. #48
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I can give you this, but it will need a little time to tidy it up and give you the formulae and code.

    Let me know if this is what you want.
    Attached Files Attached Files

  49. #49
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I think you are close to the solution.
    first three lines seem to be ok, the sixth no.

    pratically I receive a code , I have to ask the price to 3 different suppliers once received the quotations I need the average of the prices...
    I need also the date because same code could be asked many times and when I do this report I need to be sure that everything refer at the same date.

    I need also the concatenation of Code + supplier + date + price ordered (Sheet Ordinato) in this way subtracting price ordered - average of the quotations I can calculate the saving on that code


    RDO Sheet is the total amount of requests of quotation in a defined period of time , ORDINATO sheet is the file of code ordered , sheet Analisi is the sheet for calculating the saving
    Last edited by Veronique Dubois; 08-07-2023 at 10:59 AM.

  50. #50
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Can anyone help me?
    Thanks

  51. #51
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I haven't forgotten you. I've just got other stuff to do. I need to try things out. I have resolved the average problem, I think. Well, I'm pretty sure. The example you quoted of rows 70 and 72 works correctly.

    But I need to look at the other issues you mentioned.

  52. #52
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    My version of Excel (2021) does not support all the functions used

  53. #53
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    thanks guys

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

    Re: File Optimization with Macro

    Veronique Dubois,

    =MEDIA(SE(A:A=A2;D:D)) after that I copied and pasted only the value because everything got slower.
    ....
    I should have also to hide line with the text NON CONSIDERARE.
    If you are manually changing the formula to value, this is all done by vba.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  55. #55
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    This code loads all the formulae for columns A:E and J.

    Note that all the CONCAT(...) functions have been replaced by (TEXTJOIN("_", ...) functions. This allows me to separate out the different elements, for example, price, product code and vendor. I can then use product code and vendor to match entries in the RDO sheet.

    Please Login or Register  to view this content.
    The workbook is attached.

    Very important: For this to work all the CONCAT(...) functions have been replaced by (TEXTJOIN("_", ...) functions in the RDO and ORDINATO sheets.

    There is a problem with your INDEX/MATCH statements in column F and G. For example:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Here you are trying to MATCH ANALISI!C2 with ORDINATO!B:B. The issue is that C2 has price/product code/vendor. Column B on ORDINATO also has those same elements but there are no matches. I suspect that could be that the price may be different. However, if I check just the product code and vendor there are still no matches. I cannot test whether or not these formulae work as they all return "NON CONSIDERARE".
    Attached Files Attached Files

  56. #56
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I have created a new ANALISI sheet .... ANALISI2

    The new sheet requires only two formulae and it does not matter how you set up your CONCAT on the RDO sheet.

    This formula will Fetch all rows from RDO and select required columns:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This formula will Calculate AVERAGE for ALL rows
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As you can see, they are relatively simple compared to the formulae required to extract the Supplier, Product, Date and Price in the original ANALISI worksheet.

    In the sample file, there are other formulae which, hopefully, will demonstrate the validity of the calculations. You don't need them, but they might prove a useful cross reference should you have any doubts about the correctness of your calculations.

    We do, however, still need to get to the bottom of the calculations relating to the ORDINATO sheet.
    Attached Files Attached Files

  57. #57
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Further update. I have added a test record to the RDO and ORDINATO sheets. All the formulae appear to work as expected. I have included some test columns which you may wish to retain to cross check your assumptions.

    The code will create the formulae but, as the formulae are self adjusting, you shouldn't really need to to run the code.

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

  58. #58
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    If you wanted to, you could convert all the formulae to values after they have been loaded.

    Please Login or Register  to view this content.

  59. #59
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Judging by the lack of input/response/feedback over the last five days, I assume you have lost interest or found a solution elsewhere.

    If I hear nothing back today I will unsubscribe from this thread and leave it with you as it stands. I hope it does what you want.

  60. #60
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello guys, I had my Pc broken...sorry
    Now I can check your kind update !

    Which of the two macros do I have to use? Sub sAddFormulae() or Sub sAddFormulae2() ? ...maybe both? I'm sorry but you are too expert for me, I don't have enough skills to understand it correctly
    Last edited by Veronique Dubois; 08-21-2023 at 03:10 AM.

  61. #61
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Ok I think to have understand it , I have to use Sub sAddFormulae2() changing in RDO and ORDINATO the concatenations system

  62. #62
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I tried however blue columns don't work ... everything appear with NON CONSIDERARE.

    I don't know why.... I had to copy and paste your VBA code because once opened your file, my company data protection blocks your macro.
    could be the problem?
    Last edited by Veronique Dubois; 08-21-2023 at 05:55 AM.

  63. #63
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    I think that is a plausible reason.
    You cannot just copy macros without I understanding what you’re doing

  64. #64
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    tried again writing all formulae by hand but blue columns don't work.

  65. #65
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Provide a workbook for troubleshooting.

  66. #66
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I have generated this vba code, however Blue columns of TMS's File don't work
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 08-24-2023 at 03:23 AM. Reason: Code tags corrected.

  67. #67
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    I asked for a workbook with the changes you've made.

  68. #68
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    In the file analisi - copia I used the Vba code just inserted, using the formulae of TMS.

    attached both files.

    I'm bothering all of you too much...if you want close this topic

  69. #69
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Not at all - just trying to get enough information to help you!

  70. #70
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I have added the code to your latest sample file.

    I have also added a test record at the bottom of both the RDO and the ORDINATO worksheets. This demonstrates that the formulae DO work. The issue is that you do not have any matching records. I can't say this a different way. You DO NOT have any matching records. Please look at the test records and the output record in the ANALISI worksheet to understand how the formula works and what it is matching.

    Please Login or Register  to view this content.
    If you are copying the code, please copy EVERYTHING in the mANALISI module.

    The code will check if the ANALISI worksheet exists and, if it doesn't, it will create it. It then clears the entire worksheet. After that, it adds the headings (using formulae) and adds all the formulae for the analysis. Finally, it formats the columns ... headings (colour) and data (column width, number format, text wrap, etc).

    You DO NOT NEED to try and record a macros. It is all done. Just copy the code from the sample file.
    Attached Files Attached Files

  71. #71
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Is there any method to share with you the complete file? it's about 1.4 Mb and zipping it doesn't get 1Mb..

    Blue cells got some issues...they don't extend values till the end (please check the pic).
    other things I have to understand:

    - column G: does it takes the ordered price from ORDINATO Sheet ?
    - column H: does it takes the Q.ty from ORDINATO Sheet ?
    - column I: does it shows column G * I ?
    - column J: does it shows column F * H ?
    - column K: does it shows column I - J ?

    maybe the problem is that you get columns A-B-C-D-E from the RDO sheet but I need them from the ORDINATO because they are the item really ordered , basically from RDO I need only to get the average of same code from request for quotation in order to get the "total average"

    Don't kill me please
    Attached Images Attached Images
    Last edited by Veronique Dubois; 08-22-2023 at 02:50 AM.

  72. #72
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Cut down the data in the file until you have a copy that is small enough to share and that shows the issues.

  73. #73
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    If you remove all the empty columns after the last filled column as well as the last rows below the last filled cells your file will be reduced too.
    And if you save it as xlsb it's even smaller
    Attached Images Attached Images

  74. #74
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS: Please try to lounch your macro from the original file. you will see the issue written before.
    Thinking how should be correct A-B-C-D-E in the Analisi sheet have to be from Ordinato sheet not from RDO.
    Attached Files Attached Files

  75. #75
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    maybe the problem is that you get columns A-B-C-D-E from the RDO sheet . . .
    I get the data from the RDO sheet because, in your first example which only calculated the average, YOU only used the RDO sheet.

    Losing the will here.
    Last edited by TMS; 08-22-2023 at 03:14 AM.

  76. #76
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    yes you right... we can use also the RDO however it doesn't work
    are these questions correct?

    - column G: does it takes the ordered price from ORDINATO Sheet ?
    - column H: does it takes the Q.ty from ORDINATO Sheet ?
    - column I: does it shows column G * I ?
    - column J: does it shows column F * H ?
    - column K: does it shows column I - J ?

  77. #77
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    - column G: does it takes the ordered price from ORDINATO Sheet ? Yes, column Z
    - column H: does it takes the Q.ty from ORDINATO Sheet ? Yes, column V
    - column I: does it shows column G * I ? Yes
    - column J: does it shows column F * H ? Yes
    - column K: does it shows column I - J ? Yes

    I will need to investigate why the formula is not spilling down. I may be some time.

  78. #78
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    OK, at the moment, I do not know why the formula is not spilling down. There ARE matching Supplier/Product Code entries in RDO and ORDINATO so a) it should spill down and b) it should get matching values. I suspect the problem may be because there are more than one matching entries.

    Anyway, analysis so far:

    In RDO, there are 1399 rows/records, of which 1308 are unique Supplier/Product combinations, of which, 330 entries match records in ORDINATO. Similarly, in ORDINATO, 4308 rows/records, of which 3374 are unique Supplier/Product combinations, of which, 330 entries match records in RDO (as expected). There are 47 uniique suppliers in each worksheet. If we remove the uniqueness from the equation, there are 379 matching entries.

    So, the question now is, how do you want to analyse this data? Originally, it looked as though you had an entry in ANALISI for every record in RDO. Do you want to see an entry in ANALISI for every record in ORDINATO? Or, do you want to see entries for the records that match in RDO and ORDINATO. And, given there are "duplicate" entries on both sides, how do you want to cater for that?

    So, for example, a couple of matches in ORDINATO

    PHP Code: 
    ConcCode+fornitore ID    Fornitore ID    Codice Prodotto    Quantit  agrave     Prezzo
    3
    -8258/1_FI00000127    FI00000127    3-8258/1    48    7.8
    3
    -8258/1_FI00000127    FI00000127    3-8258/1    32    7.8
    3
    -8258/1_FI00000127    FI00000127    3-8258/1    80    7.8
    3
    -13155_FI00000127    FI00000127    3-13155    36    6.9
    3
    -13155_FI00000127    FI00000127    3-13155    44    6.9 
    Note that there are "duplicate" Supplier/Product entries and the quantities are different but the price is the same.

    Over to you to give it some thought and make some decisions.

    Whatever you decide, I suspect it's back to the drawing board. Good job I'm not charging you for my time

  79. #79
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello,
    I thought about what I need for getting the results.

    if you see my starter file at the beginning of this topic, in the first column there is the concatenation of the codes with the date, this it's important because usually a codes have to be asked to three suppliers and this happens in the same date!
    later on once I received their prices I need to calculate the average of them.. so :

    - one column with : the average of code issued in the same date of the RDO sheet
    - one column with : the Quantity ordered so column V of ORDINATO
    - one column with : the price ordered so column Z of ORDINATO
    - one column with : total price ordered so Z * V
    - one column with : the average of code issued in the same date of the RDO sheet * Quantity ordered
    - one column with the saving : total price ordered - ( the average of code issued in the same date of the RDO sheet * Quantity ordered )

    when I have these data I'd like to see an entry in ANALISI for every record in ORDINATO ( I need to analyze them because they generate savings).
    About duplicate... the only way to discriminate them is to compare the quantities from: supplier/code/q.ty of RDO sheet and supplier/code/q.ty of ORDINATO sheets in order to be sure that I'm analyzing the correct order ...so this is another calculation I cannot use date in this case because order is not in the same day of the request for quotation

    I am so sorry for wasting your time, don't feel obliged to help me
    I don't even know if I'm clear...

  80. #80
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Where is the workbook we need to be looking at?

  81. #81
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Please take two or three specific examples of requests for prices in RDO and the matching entries in ORDINATO and manually show what you expect to see. I can't get my head round checking 4000+ ORDINATO records.

    I am struggling to understand how you relate RDO requests for product/date to the entries in ORDINATO (which has lots of dates but not, as far as I can see, the date the quote was requested in RDO.

    I can understand getting an average of product/date requests. What I don't understand is how to relate them to entries in ORDINATO.

    I can easily produce entries in ANALISI for every record in ORDINATO, but is that realistic? If I have interpreted the data correctly, many of the records in ORDINATO do not have matching supplier/product entries in RDO. If that assumption is correct, you won't get an average price to use in your calculations.

  82. #82
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    please check the attached example
    Attached Files Attached Files

  83. #83
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: just to reassure you that I am still looking at this, and getting close (I think).

    I have a couple of issues to try and understand and resolve and I will let you have an update. I may need to come back and ask for clarification of a couple of scenarios.

  84. #84
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS thanks I really appreciate your efforts ! it's important but not so urgent

  85. #85
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: I think this is working . . . but what do I know?

    I was having some trouble with the dates converting erroneously. That is, things like 05/03/2023 changed to 03/05/2023 and, consequently, I was not able to match them. That seems to be fixed now, fingers crossed.

    Please note that the macro converts the formulae to values except for the first row. That is intentional so that it is easier to be able to check what is going on.

    There is a lot of diagnostic information on the right hand side which I think is still quite useful at this stage. It is my intention to make it possible to switch that on and off. However, I don't have time at the moment. Where data is available on the RDO sheet, the diagnostics will list the date(s) and value(s) for the products, as well as checking minimum, maximum, average and count of values.

    Please note that some products have more than one date. It is not immediately obvious to me which I should pick so I have taken the first.

    There are 436 records on the ANALISI sheet that have dates/values on the RDO sheet (out of 438).

    Let me know if this is what you were expecting.
    Attached Files Attached Files

  86. #86
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    Dates have been a serious issue when working within Excel.
    When using VBA you should always save the date as a number and not as date.
    The cell formatting serves only to view the data in the cell but when calculatin dates as a number you will not get the date 'changing' like you mention
    03/05/2023 (45049) or 05/03/2023 (44990)
    Als when you sort the dates the sorting as a number will always be correct
    When you include the time value : NOW() 10/09/2023 08:59:57 (45179.3748842593)
    You play around with it and you will understand what is happening and will be able to solve it

  87. #87
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah: thanks for your comments. I know what was happening and why. And also the problems associated with VBA and dates. However, I was trying to keep them displayed as dates in the ANALISI worksheet especially where there was more than one date for a product.

    Because there can be more than one date, I am collating them as text values. For performance reasons, I convert the formulae to values. But, if there is only one date, and the day is less than or equal to 12, Excel can and does mess it up.

    I overcame the problem by dropping the formula in, then formatting the cells as text before converting to values. That seems to have worked.

    If not, I will have to follow your advice. We'll see.

  88. #88
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: This, I hope, is the final version . . . at least for this stage of the development. There may be changes subject to your requirements.

    The ANALISI sheet is purposely not present. The first thing you need to do is read through the Information sheet and then run the sAddFormulae macro. Diagnostic mode is switched off. If you want to try it, please follow the instructions in the Information sheet.

    I'm going to be away for a few days so I won't be able to make any changes until I get back . . . no macro development on an iPad

    Good luck.
    Attached Files Attached Files

  89. #89
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    @TMZ: you've outdone yourself, nice job

  90. #90
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah: thank you . And thank you for the +rep
    Last edited by TMS; 09-11-2023 at 03:12 AM.

  91. #91
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS thanks for the support in the next few days I will check and I'll give you a feedback !!

  92. #92
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: enjoy. I hope it gives you the results you expect . . . or, at least, results you will understand.

  93. #93
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello @TMS,

    How can I copy this Macro in my file?
    I'd like to test it but I have problem... do I have to copy the code in my file?
    do I have to do any operations in sheet named RDO and ORDINATO?

  94. #94
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Hi Veronique

    How can I copy this Macro in my file?
    I'd like to test it but I have problem... do I have to copy the code in my file?
    Yes, you will need to copy the code to your file.
    The easiest way, I think, is to open this test/demonstration workbook and your file. Then, in the Visual Basic Editor, drag all the modules across to your file. There is no code in the RDO or ORDINATO worksheets, or the Workbook module.

    do I have to do any operations in sheet named RDO and ORDINATO?
    No, not in the worksheets themselves.
    But you will need to set up the Dynamic Named Ranges. I have created a macro, sAddNamedRanges, to do that.

    Please Login or Register  to view this content.
    And I have attached the latest updated workbook. Please read the Information sheet carefully. It should explain everything but, if not, let me know. I suggest you run the code on a copy of the live workbook. The code does not make any changes to the RDO or ORDINATO worksheets.

    Did you try running the sAddFormulae macro in the sample workbook? If so, did the results look as you would expect them to?
    Attached Files Attached Files

  95. #95
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: hang fire. You can run the macros without copying them into the live file. I will send you a new file with just the macros and instructions on how to run them.

  96. #96
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique

    A quick follow up. You can run the macros without copying them to the live data file. I have just tested it, and it works.

    I have attached a workbook that only has the code in it. It has no data, and it has no Named Ranges.

    The Information sheet in this workbook explains how to run the macros.

    In brief, open the macro file first. Then open the data file so that it becomes the Active Workbook. Then you can press Alt-F8 to see the macros in the Code workbook. Run sAddFormulae.
    Attached Files Attached Files

  97. #97
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS please see the attached, I've run the macro but is not working.
    I am sure that it's my fault.

    How do I have to set RDO and ORDINATO pages?
    I promise to close this discussion after your answer
    Attached Files Attached Files

  98. #98
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: My guess is that it has something to do with our different Regional Settings, specifically for the date format.

    I will have to experiment and see what I can do to overcome the issue.

    You don't need to close the thread just yet. We have, I think, come a long way and it would be a shame not to see it to a conclusion.

    In the meantime, here is a copy of the updated workbook ... the macro works for me hence the reason for thinking it has something to do with the dates.

    Maybe you can check if the figures look as you expect them to?
    Attached Files Attached Files

  99. #99
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62
    Tomorrow I Will try.
    I Need this file now so I have tò find a solution ASAP.
    I ll let you know

  100. #100
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS
    The data in ANALISIy seems to be correct.
    now I have two questions:
    - how do I have to set RDO and ORDINATO sheets before launching the macro?
    - What did you change in the last file? where can I copy the last macro review?

  101. #101
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    Check your data set this column to TEXT to avoid the automatic interpretation en setting a value to a data
    Attached Images Attached Images

  102. #102
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    thanks Keebellah !
    now I need the TMS's feedback about my questions above

  103. #103
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS can you help me with this?
    Now It s urgent 😔😔

    how do I have to set RDO and ORDINATO sheets before launching the macro?
    - What did you change in the last file? where can I copy the last macro review?

  104. #104
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique: please try this new version.

    I think the problem is most likely to do with different date formats. Originally, I was trying to make the dates in column C readable as dates, but I think that is the issue. I have changed the macro now so that the values in column C are just the numeric representation of the dates. For example, 4th October 2023 is 45203. On my system, with my settings, that would display as 04/10/2023 but I am guessing it might be different on your system. Hopefully, this will fix it.

    I have, however, output the readable dates in column L. They are only there for convenience and not used elsewhere in any formulae.

    You do not need to do anything to the RDO and ORDINATI worksheets provided the columns remain in the same order as they are now.

    Please follow the instructions: open the macro file first but do not run any macros. Then open the data file so that it is the active workbook. Then run the macro.


    Bon chance. Buona fortuna. Good luck.
    Attached Files Attached Files

  105. #105
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Note you do not have to copy the macro to your file. In fact, if you do, it won't run.

    When you down load the macro file, you will need to navigate to the file in your download folder, check the properties and unblock it. Otherwise, you can't enable the macros. Guessing you have done this before though ... but I thought I'd best double check.

    As I said before, please just follow the instructions.

  106. #106
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah
    Dates have been a serious issue when working within Excel.
    When using VBA you should always save the date as a number and not as date.
    The cell formatting serves only to view the data in the cell but when calculatin dates as a number you will not get the date 'changing' like you mention
    03/05/2023 (45049) or 05/03/2023 (44990)
    Als when you sort the dates the sorting as a number will always be correct
    When you include the time value : NOW() 10/09/2023 08:59:57 (45179.3748842593)
    You play around with it and you will understand what is happening and will be able to solve it
    @Keebellah: thanks for your comments. I know what was happening and why. And also the problems associated with VBA and dates. However, I was trying to keep them displayed as dates in the ANALISI worksheet especially where there was more than one date for a product.

    Because there can be more than one date, I am collating them as text values. For performance reasons, I convert the formulae to values. But, if there is only one date, and the day is less than or equal to 12, Excel can and does mess it up.

    I overcame the problem by dropping the formula in, then formatting the cells as text before converting to values. That seems to have worked.

    If not, I will have to follow your advice. We'll see.
    Well, I finally had to give in and follow your advice . The macro still works on my side, so let's hope it works for Veronique.

  107. #107
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62
    I try this morning, however I use It on my PC at work and data security blocks the macro because classified as Dangerous,for this reason I copied the macro in my Personal folder and tried ti launch It from there..
    I'll keep you updated

  108. #108
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    If this file is so important you can ask the person responsible for your netwrok to mark the file as trusted.
    It's not a question to copy and so but then make it useable.
    You cannot compare a local system to a newtrok

  109. #109
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    @TMS; I've been struggling with dates in Excel for ages, when I think I've got it right a new issue pops up and messes it up, especially when it comes to importing or reading external data.
    I always conver my dates to double values for date and time and it's getting bteer, but still after more than 35 years of coding ...
    Now again Oktober 10 shows up sometimes as 04/10/2023 (dd mm yyyy) or 10/04/2023 (mm dd yyyy) so I decided to not use dates before the 13th of each month
    Serioulsy date has to be read as a double adn then format as the user likes. I also use a Function to check the system settings

  110. #110
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    Now It s urgent 😔😔
    Véronique - whilst I understand that you may be in a bit of a panic now, don't tell us that it is urgent, please. All your helpers here are volunteers giving freely of their own time: you haven't paid a penny for any assistance you get here, therefore expecting any form of speed response or preferential treatment, or seeming to, is inappropriate.

    Thank you for your understanding. If you are pressed for time, consider finding a paid 24/7 agency who can do the job for you. This is not a service like that.

    Moderator

  111. #111
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    It WORKS !!!!!
    Please TMS do you have PayPal I'd like to offer to you at least a "virtual" beer

  112. #112
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    @Véronique

    General Guideline #4 on the Forum Rules Page states:

    4. As this is a free forum where members are not allowed to ask for payment, please don't offer it, as it is contrary to the community ethos of the forum.
    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  113. #113
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Véronique

    OTG. Thank you for the kind offer of a "virtual" beer, but that is not necessary. The satisfaction (and relief) for providing a solution to an interesting problem is enough. I don't bother much with VBA these days, so it is good to have a challenge every so often.

    It is not necessarily your IT people stopping you using macros. More likely Microsoft making it more difficult to use them as a security measure. Hence the reason for unblocking the downloaded macro file.

    Anyway, enjoy

  114. #114
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS: Now I cleaned all data not necessary.
    Have you any suggestion for fixing the dates in column C?
    Do you know why sometime column B change the code? for example line 88 or 140-141-142 the code in column B is not correct.
    have you any suggestions?
    Attached Files Attached Files

  115. #115
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    OK, so I'm a little confused. The file that you have attached now has more data in both RDO and ORDINATO sheets. But the ANALISI sheet does not have column L. Therefore it is a different file to the previous ANALISI.xlsb that we started with. However, it cannot have been processed by the latest code which adds column L.

    Did you use the new macro? You must have because of the date format. But where is column L?

    As has been mentioned and discussed several times, I wanted to have "readable" dates in column C on the ANALISI sheet. But that causes a problem, not for me using my Regional/Country settings, but for you and your settings. So, I had to resort to using the numeric values of the dates in column C as the formulae in columns D and E depended on using the dates in column B. As a workaround, I output the readable dates in column L.

    I may be able to swap them around but it affects several formulae so I'll need to retest everything.

    Do you know why sometime column B change the code? for example line 88 or 140-141-142 the code in column B is not correct.
    Some 412 records on the ORDINATO sheet have values in column M (Codice Prodotto) that are interpreted as dates, at least on my system. The underlying numeric value is correctly extracted and output in column B on the ANALISI sheet. Rows 88, 140, 141, and 142 are some examples of this.

    For example, on the ORDINATO sheet Row 88 has 1872659_FI00004535 in column A. 1872659 is from column M which shows as Mar-27 ( 01/03/7027 ). This was highlighted by Keebellah in post #101. Looks like Keebellah sees the same data and presentation as I do.

    I have made a slight modification to the code so that these values are output as Text values

    Please note that I make no changes to the data in the RDO or ORDINATI sheets.

    Latest macro file and updated sample attached.
    Attached Files Attached Files

  116. #116
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I launched the latest version, seems to be ok.
    column L before I deleted it because doesn't work on my excel.

    File has different data because I have to launch this operation every six months so I have downloaded the latest data.
    Attached Files Attached Files

  117. #117
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    OK, try this one. Different formula in column L that takes its data from column B, which we know does work.
    Attached Files Attached Files

  118. #118
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    It doesn't work

    in attached the latest file
    Attached Files Attached Files

  119. #119
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Ah, this is getting frustrating

    Try one of these formula in cell L2 and copy down. If it works, I will update the macro and upload it.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  120. #120
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    no.. they don't work .
    just for info I have to use ; not , in the formulas

  121. #121
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    If you change the commas to semi-colons, do they work then?

    All the other formulae work with commas.

    What format do you use for dates?

  122. #122
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    for dates is TEXT .
    with semi colons doesn't work.

    I was looking also that column D and E have same values, what is the difference in the calculation?

  123. #123
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    See if it works with this updated macro. I assume/hope that the VBA will convert the formulae to the local settings.
    Attached Files Attached Files

  124. #124
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I was looking also that column D and E have same values, what is the difference in the calculation?
    It's not a calculation. The values come from columns Y and Z in the RDO sheet. They are the same, apart from 13 records out of 1652.

    PHP Code: 
    Prezzo    Prezzo from Supplier
    0    21.5
    0    2
    ,920
    26    28
    0    520
    0    520
    0    330
    0    950
    0    530
    0    23.5
    0    21
    450    450
    ,000
    250    250
    ,000
    480    480
    ,000 
    PHP Code: 
    Fornitore ID    Codice Prodotto    Data Emissione    Prezzo    Prezzo from Supplier    Average
    FI00000182    3
    -4394/14    44904    2320_3060_0    2320_3060_21.5    1793.33
    FI00003257    3
    -3333/178    44904    360_473_400_0    360_473_400_2920    308.25
    FI00010304    4
    -6772/2    45001_45008    55_26    55_28    40.50
    FI00002392    4
    -65338/59    45049    539.05_450    539.05_450000    494.53
    FI00002392    4
    -33797/120    45049    186.28_250    186.28_250000    218.14
    FI00002392    4
    -65338/58    45049    660.55_480    660.55_480000    570.28 

  125. #125
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Ok now I understand. Which one use column Z of RDO?

  126. #126
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    This:

    ANALISI D = RDO Y
    ANALISI E = RDO Z

    ANALISI F (Average) uses RDO Z

  127. #127
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS:
    Column L still doesn't work.
    Anyway I showed this file to my colleagues and they claim just another correction.
    I try to explain it...

    if the ordered date (in ORDINATO) is later than RDO date (considering same codes) than I have to collect the saving otherwise the order is not referred to the correct RDO and is useless.

    if you check now the file, there are red cells with same values if you check for ex. line 121 code 3-3329/6 is repeated three times , the real saving is just in the line 121, the lines 122 - 123 have to be hidden
    because are done before the RDO date of the same code.

    Hoping it's clear

    I think the only way is to use dates in some way... but this beats me... you are the lonely here able to do it
    Attached Files Attached Files

  128. #128
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    @TMZ: I'd like to help but my Excel version (2021) does not support many of the used builtin functions like TEXTSPLIT.
    Pity

  129. #129
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Bit of an eleventh hour curveball . Any thoughts on a different approach would be appreciated.

  130. #130
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    @TMS: Your code looks great and I understand it but I would have to write an alternative for TEXSPLIT as UDF using a version check to run one or the other, once that's done the challenge is there to see what happens on the OP's side to figure out what's happening.
    Local settings and more. You're the one that did a great jog but the feedback is the problem and troubleshooting always takes time

  131. #131
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Yup. It has taken a long time to get to this point. Having got it to work at all, I am bemused that it won't show readable dates based on numeric dates. But that's the least of the problems now.

  132. #132
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    @TMS:
    another thing.
    I know you use them for calculations, but is there any chance to visualize date in the analisi sheet? because in that format are useless to me

  133. #133
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    I started out with readable dates in column C which worked for me but not for you. So I had to use numeric values for everything else to work. Then I tried to output readable dates in column L, which also works for me but not for you. What format do you see dates?

  134. #134
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    in any format I don't see the date. (check the pictures there is also my language settings)

    what do you think about the other improvement? to read only the orders made after the RDO date? is it feasible in your opinion?
    Attached Images Attached Images
    Last edited by Veronique Dubois; 10-06-2023 at 07:39 AM.

  135. #135
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    Well, it's gonna be a tough one for the OP

  136. #136
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    what do you think about the other improvement? to read only the orders made after the RDO date? is it feasible in your opinion?
    Maybe. I'm thinking about it. I hope so.

  137. #137
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah: I think I have a solution to the latest rider. I tested an extra filter last night and it looked as though it might work. I need to do some tidying up to offer it as a solution though. And I am thinking the readable dates might just be a case of using Italian date format. We'll see.

    PM Inbox has space now

  138. #138
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Yes I'm sure you can do it.
    did you get my current problem in the file? it's so difficult for me to explain it in english.

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

    Arrow Re: File Optimization with Macro


    Salut !

    To stop this NES - Never Ending Story - as an exception try to explain in french - mais sois vraiment claire et concise, rien de superflu ! - and
    I will try to translate for helpers …

    So weird you created this thread in an english forum as several french Excel forums exist !

  140. #140
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    I think TMS has understood .
    everything is correct just need two things:
    - date in the correct way
    - In the analisi Sheet I need to visualize the line only if the ordered date (in ORDINATO) is later than RDO date considering same codes

  141. #141
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    - date in the correct way
    Is that just not a case of setting the formatting of the column to SHORT DATE? You do this on the HOME ribbon.

  142. #142
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Ali:
    Is that just not a case of setting the formatting of the column to SHORT DATE? You do this on the HOME ribbon.
    There can be more than one date and the date values are concatenated. Hence the column is formatted as text. The date(s) can be converted back to a numeric value for use in other formulae. I have tried to output the dates in readable format elsewhere . . . which works for me but not for Veronique. I am going to try something else.

  143. #143
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Please see if this version works for you.

    I have implemented the date comparison. The numeric dates are still in column C for calculation purposes. However, I have output the dates in numeric and readable format in columns M:P for ease of comparison. The readable dates should be in "yyyy-mm-dd" format rather than "dd/mm/yyyy" format. Hopefully this will overcome the presenation issues (#VALUE!).

    If it does work, I will tidy up the documentation.
    Attached Files Attached Files

  144. #144
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Hello TMS now it doesn't work the rest of the file too.

    please check the attached
    Attached Files Attached Files

  145. #145
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    That is certainly an unmitigated disaster. However, it is not (necessarily) anything to do with the dates. In this instance, it is most likely to do with the fact that the data structure on the Ordinato sheet is different to the files previously processed.

    Whilst it might be possible to work around this change of layout ... the product code is in a different column ... it does indicate a potential level of inconsistency in your data extraction process.

    I cannot guarantee to make the code foolproof if that is a possibility.

    I need you to test the new code with one of the earlier files to see if it has addressed the date comparison rider and also the presentation of readable dates.

    I am not prepared to do any further work on this application until that has been checked.

  146. #146
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Unhide column I on the Ordinato sheet. The column has been inserted, a formula ( ? ) put in a cell, and the column hidden for some reason.
    Last edited by TMS; 10-10-2023 at 07:04 PM. Reason: Wrong column reference

  147. #147
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    I've got the feeling here that you offer a finger and the whole hand is taken.
    The string of thought and information offered doesn't give a 100% clear view but you have really gone deep into it here.
    Pity I'm not on Excel 2023 or 365

  148. #148
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62
    @TMS I try again ASAP.
    Maybe meanwhile I was waiting for your update I did some test and I changed some column.

    Please be patient not every people Is good as you in excel.
    Last edited by AliGW; 10-11-2023 at 02:11 AM. Reason: Inappropriate comment removed.

  149. #149
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    Quote Originally Posted by TMS View Post
    Unhide column I on the Ordinato sheet. The column has been inserted, a formula ( ? ) put in a cell, and the column hidden for some reason.
    you right I made an attemps and I forgot to delete it.
    anyway dates don't work yet
    check the attached
    If I had dates I could manually delete lines of the order made before the RDO date.

    I think we are close to the solution, I don't want to give up now
    Attached Files Attached Files

  150. #150
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    Hi Veronique,
    You give up very easily but if you look at your file you just uploade,
    1. I noticed in ANALISI is that in column M your header says: ORDINATO DATE (N) but column N in ORDINATO does NOT contain any dates so where does that come from?

    2. ANALISI column N says: ORDINATO DATE (T) this column does contain dates but only the format text is shown not the result found in ORDINATO column T, correct this in the macro.


    One more ting and that is something I always do is Freeze the top rows so that you view the rows and have the header always visible
    I have attached your own file in a way I would suggest you to do that to be able to read the contents better.
    About the macro's well, you'll have to check that becasue on my system the do not work because I do not have Excel 365
    Attached Files Attached Files

  151. #151
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Keebellah:

    ORDINATO DATE (N) is the numeric value of the date column. ORDINATO DATE (T) should be the text representation of the dates in the same column. They are the output, not the source.

    @Veronique: when you format a date, what letters are used for year and day? So, I use "dd/mm/yyyy". I thought that using "yyyy-mm-dd" would be enough. Looks like the format is ok but the letters for year and day are wrong.

    I think I may have discovered the solution. Back later.

  152. #152
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    The OP is in Italy. Italian date format is dd/mm/yyyy but might need the annotation gg/mm/aaaa (giorno, mese, anno). However, she's French, so if using a French locale it would be jj/mm/aaaa (jour, mois, an).

  153. #153
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Thanks Ali. I will offer some different presentations later. Think it is very close now.

  154. #154
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Veronique

    I have followed Ali's suggestion and output the readable dates with format "aaaa-mm-gg;@". Hopefully, this will present the dates as you need to see them. They look rubbish on my end, so I'm hoping it has had the desired effect.
    Attached Files Attached Files

  155. #155
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    @Ali: you might find this interesting: https://www.myonlinetraininghub.com/...rent-languages

  156. #156
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: File Optimization with Macro

    True, this is known, but keep in mind that the cell content is text and not a date for the purpose of calculations and comparissons

  157. #157
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    Columns C (for RDO) and M (for ORDINATO) are used in the formulae for filtering and comparison (now) and they contain the numeric versions of the dates. That said, the RDO dates are concatenated but split for comparison.

  158. #158
    Registered User
    Join Date
    07-19-2022
    Location
    Milan
    MS-Off Ver
    Microsoft365
    Posts
    62

    Re: File Optimization with Macro

    It seems to work !! I see dates in column N and P

    GREAT WORK !

  159. #159
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,891

    Re: File Optimization with Macro

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  160. #160
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: File Optimization with Macro

    That's a relief

+ 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] Code optimization to avoid multiple file open calls
    By smpita in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2014, 01:31 PM
  2. Optimization of Excel file containing VBA
    By crycx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-02-2013, 08:07 AM
  3. Excel File Optimization - lots of problems
    By ashutoshsethi in forum Excel General
    Replies: 8
    Last Post: 06-18-2013, 01:42 PM
  4. Help with Optimization Macro..
    By zealot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2013, 06:35 PM
  5. [SOLVED] Macro optimization for speed
    By mlegge04 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-07-2012, 10:20 AM
  6. Macro Optimization
    By intelligents in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2008, 05:56 AM
  7. Macro Optimization
    By RH+ in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-14-2007, 06:37 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