Results 1 to 18 of 18

Thread: Adding a new product to a product database and exporting the amount

  1. #1
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location

    Adding a new product to a product database and exporting the amount

    Hello everyone,
    I have been using this table for many years, in which I have 2 worksheets and in one all expenses (invoices) are recorded.
    In the worksheet Fakturi , I have a column Q , in which I add if there are new things, products or whatever.
    Then, through a drop-down menu in column B6:B65, these products come out to be selected.
    So far everything is OK.
    Now, however, in the worksheet SLUJITELI , in column G8:G38, the expense (amount) is displayed according to the corresponding date.
    To make things happen, use this formula in the cells:


    =IF(SUM(SUMIFS(FAKTURI!$H$6:$H$65;FAKTURI!$B$6:$B$65;{"PRODUCT 1";"PRODUCT 2";"PRODUCT 3";"PRODUCT 4";"PRODUCT 5"};FAKTURI!$A$6:$A$65;SLUJITELI!$A8)))=0;"";SUM(SUMIFS(FAKTURI!$H$6:$H$65;FAKTURI!$B$6:$B$65;{"PROUKT 1";"PRODUCT 2";"PRODUCT 3";"PRODUCT 4";"PRODUCT 5"};FAKTURI!$A$6:$A$65;SLUJITELI!$A8)))


    My problem here is that if an employee in the file needs to write a new product in sheet FAKTURI, column Q, if I don't enter it (add it) in the formula, it doesn't show up and doesn't calculates. This is because the file is locked so that no one can delete anything (completely normal).


    Here is the problem: how can any employee add a new product to column Q, somehow be able to add it to the formula and calculate it, without the employees unlocking the file, somehow things happen automatically?

    I tried to somehow change the formula, but things aren't working out for me and I'm definitely messing something up somewhere.

    =IF(SUM(SUMIFS(FAKTURI!$H$6:$H$65;FAKTURI!$B$6:$B$65;{FAKTURI!Q2:Q1000};FAKTURI!$A$6:$A$65;SLUJITELI!$A8))=0;"";SUM(SUMIFS(FAKTURI!$H$6:$H$65;FAKTURI!$B$6:$B$65;{FAKTURI!Q2:Q1000};FAKTURI!$A$6:$A$65;SLUJITELI!$A8)))


    Thanks for the help everyone with any ideas on how to make things happen.
    Attached Files Attached Files
    Last edited by k0st4din; 12-04-2025 at 02:08 AM.

  2. #2
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    Maybe you wanted:
    =IF(SUM(SUMIFS(FAKTURI!$H$6:$H$65,FAKTURI!$B$6:$B$65,FAKTURI!Q2:Q1000,FAKTURI!$A$6:$A$65,$A10))=0,"",SUM(SUMIFS(FAKTURI!$H$6:$H$65,FAKTURI!$B$6:$B$65,FAKTURI!Q2:Q1000,FAKTURI!$A$6:$A$65,$A10)))
    Or:
    =LET(t,SUM(SUMIFS(FAKTURI!$H$6:$H$65,FAKTURI!$B$6:$B$65,FAKTURI!Q2:Q1000,FAKTURI!$A$6:$A$65,$A9)),IF(t=0,"",t))
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  3. #3
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Hello, now I'm going to try to see if things will work out.
    I was wondering in the second formula, where does this "t" come from and what does it mean?
    =LET(t,SUM(SUMIFS(FAKTURI!$H$6:$H$65,FAKTURI!$B$6:$B$65,FAKTURI!Q2:Q1000,FAKTURI!$A$6:$A$65,$A9)),IF(t=0,"",t))

  4. #4
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    It will only work in the newer versions of Excel, Excel 365.

    Within the LET function, you can set variables, for example:
    t = SUM(SUMIFS(FAKTURI!$H$6:$H$65,FAKTURI!$B$6:$B$65,FAKTURI!Q2:Q1000,FAKTURI!$ A$6:$A$65,$A9))
    Now that t holds the result of that formula, you can use: IF(t=0,"",t)
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  5. #5
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Hello, something is not working for me.
    I'm uploading the table again with your new formula.
    I have values ​​for dates 4th and 3rd, but it doesn't show me the values.
    Can you take a look to see if I've made a mistake somewhere?
    The test is with the first formula.


    Thanks in advance.
    P.S. Another thing, in your formula I somehow don't see the column &Q$3:$Q$1000, from where the comparison and, accordingly, the addition of other products will be made.
    To avoid this additional post
    {"PROUKT 1";"PRODUCT 2";"PRODUCT 3";"PRODUCT 4";"PRODUCT 5"}
    Attached Files Attached Files
    Last edited by k0st4din; 12-04-2025 at 06:23 AM.

  6. #6
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    The below, gave me a result. I have made all of the ranges being checked the same size:
    =SUM(SUMIFS(FAKTURI!$H$6:$H$1000,FAKTURI!$B$6:$B$1000,FAKTURI!$Q$3:$Q$1000,FAKTURI!$A$6:$A$1000,$A10))
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  7. #7
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Hello again,
    I think you don't see my formula well.
    It takes and searches in column B in the Fakturi worksheet the words that until now, if there is a new product, I added and wrote by hand in the SLUJITELI worksheet in column G range.
    I try not to do this. And even if a macro could add new products when they are added to the Fakturi worksheet and return the sum, because - Yes, it gives a result but it is equal to zero, because it doesn't know what to find.
    I will attach pictures.
    Maybe something is confusing you, because the result cannot be given to me as a sum of 0.
    On 3.11 and 4.11 in the example I have Product 4 and Product 3 in the Fakturi sheet, respectively in the SLUJITELI sheet, I should have the sum of 35(G10) and 150(G11), and it gives me a result of 0 (because it doesn't know what to find and what to search for in the database from column Q
    Attached Images Attached Images

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,512
    Location
    Instead of using defined ranges like Q2:Q1000, try naming the range as a table. Simply add your new product to the table and the formulas should all adjust automatically
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Hello, you want to tell me to use my formula again, only to put the given name in the special quotes. Is that how I understand it, i.e. instead of {Product 1, Product 2}, it should have some name, for example {Goods}. In the other worksheet, I only look for the money, but as I wrote at the beginning, if a new product is inserted, I always have to go to the Slujiteli sheet and add the product by hand in the formula. I am looking for an alternative to make things happen automatically. Please look at my formula in the first question. Thank you very much.

  10. #10
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Hello,
    I'm trying to do this with a macro for example.
    The idea is that I add a new product in a column from Q3 down and it automatically "enters" the drop-down menu to be selected in a cell in column B6:B65 in the "Fakturi" sheet, then in the other sheet Slujiteli, in column G8:G38 according to the date, only the amount can be calculated and I can only see it (regardless of how many products there are for a given date).
    I say again, now I do it with the formula shown in my first post, but every time someone adds a new product in column Q, the product is not visible and I have to add it manually to start calculating it in the Slujiteli sheet in column G8:G38.

    This is a macro made by hand because I can't make it 100% correct, but you can at least see what my idea is.
    Sub addnewproduct()
    
    
        Sheets("FAKTURI").Select
        ActiveCell.FormulaR1C1 = "next product add 1"
        Range("Q11").Select
        ActiveCell.FormulaR1C1 = "next product add 1"
        Range("Q12").Select
        Sheets("SLUJITELI").Select
        Range("G8").Select
        ActiveCell.FormulaR1C1 = _
            "=IF(SUM(SUMIFS(FAKTURI!R6C8:R65C8,FAKTURI!R6C2:R65C2,{""next product add 1"";""next product add"";""PRODUCT 1"";""PRODUCT 2"";""PRODUCT 3"";""PRODUCT 4"";""PRODUCT 5""},FAKTURI!R6C1:R65C1,SLUJITELI!RC1))=0,"""",SUM(SUMIFS(FAKTURI!R6C8:R65C8,FAKTURI!R6C2:R65C2,{""next product add 1"";""next product add"";""PROUKT 1"";""PRODUCT 2"";""PRODUCT 3"";""PRODUCT 4"";""PRODUCT 5""},FAKTURI!R6C1:R65C1,SLUJITELI!RC1)))"
        Range("G8").Select
        Selection.AutoFill Destination:=Range("G8:G38"), Type:=xlFillDefault
        Range("G8:G38").Select
        
        Range("G8").Select
        Selection.Copy
        Range("G9:G38").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
       
        Range("B8").Select
    End Sub

    I don't know if I'm explaining it correctly.
    Thanks in advance for any help from you.

  11. #11
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Aussiebear,
    I tried your suggestion, but again the amount doesn't work for me.
    2025-12-05_102235.jpg

  12. #12
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    Out of interest, what version of excel do you run this spreadsheet on?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  13. #13
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Personally, I use Excel 2007, but this formula has never given any computer a problem, regardless of what Excel was used.
    I'm curious how these brackets { } do this "focus"

  14. #14
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    Anything between the {} is an array, Excel only allows static values in a formula array. I am not saying you will get a problem with the formula, there are just much easier ways of doing things in the latest versions of Excel. Functions like UNIQUE and other array formula that can be referenced in data validation etc.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  15. #15
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Okay, can we find a solution or will I have to continue the old way?

  16. #16
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    So is the formula in the attached not giving you a result?
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  17. #17
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,315
    Location
    I think it should be FAKTURI!$Q$2:$Q$1000 instead of FAKTURI!$Q$3:$Q$1000 also
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

  18. #18
    VBAX Mentor
    Joined
    Sep 2012
    Location
    London
    Posts
    301
    Location
    Oh, oh, oh, it will work of course, because I was an oligophrenic with this small detail of these { } and to press ctrl + shift +enter


    Thank you very much and I apologize for what I did
    You have no idea how grateful I am.
    Be alive and well and still so dedicated.
    A bow to you.
    Greetings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •