+ Reply to Thread
Results 1 to 46 of 46

merge TOTAL row for each sheet based on selected name from combobox on userform

  1. #1
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    merge TOTAL row for each sheet based on selected name from combobox on userform

    Hi
    in combobox1 will match name with column C across sheets . should merge amount for every TOTAL row for every sheet alone for th same name just PAID word in column E for each sheet alone.
    textbox1= BUYING sheet
    textbox2=SALE sheet
    textbox3=REVERSING sheet
    textbox4=VERTING sheet
    textbox5=textbox1-textbox2-textbox3+textbox4
    without forgetting number format "#,##0.00"
    and if the name doesn't contain data in other sheet then will be one of textbox should show" - "
    and I would fixing code in combobox1 to populate all of names across sheets without duplicates an empty.
    example:
    select CR-1000 from combobox1 and match with column C across sheet and then should merge for each sheet alone .
    also should deal with big data almost 7000 rows for ach sheet.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by KalilMe; 05-19-2024 at 07:20 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    How is Combobox1 to be populated?
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    should populat names based on column C across sheets and exclude duplicates names
    as I try doing in UserForm_Initialize()
    Last edited by KalilMe; 05-18-2024 at 07:53 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I removed name from "TOTAL" lines to have consistent formatting on all sheets. And RESULT button not required.
    Attached Files Attached Files
    Last edited by JohnTopley; 05-18-2024 at 09:04 AM.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    I spotted an error so use the attached file: amended code highlighted in previous post.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    thanks.
    how I get rid of empty in combobox1,please?

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    it's perfect
    just I would add column E so should merge based on name in column C and just PAID word in column E for each sheet alone.
    sorry about new requirement !
    thanks again
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JohnTopley; 05-19-2024 at 07:04 AM.

  10. #10
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    it's awesome !
    just I tested with more random data like 4000 rows for each sheet ,I note it delays some time to open the form.
    is there way to make fast when open the form,please?
    thanks gain.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    The delay is caused by the logic to obtain a unique list of names in the Initialise Step: I'll look to see if there is a better way.

    Please post a file with large volumes so I can test any change.

    Will any ONE sheet ALWAYS contain ALL names e.g BUYING [rather looping through all sheets]?

    If using BUYING to extract names is OK then easist change is ....

    Please Login or Register  to view this content.
    Last edited by JohnTopley; 05-20-2024 at 06:21 AM.

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

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

  13. #13
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    thanks jinon , but also should merge based on PAID word in column E , not only name in olumn C
    I think the code will just merge based on name in column C !

  14. #14
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Will any ONE sheet ALWAYS contain ALL names e.g BUYING [rather looping through all sheets]?
    unfortunately in SALE sheet contains names are not existed in BUYING sheet.

    Please post a file with large volumes so I can test any change.
    just copy random data.
    Attached Files Attached Files

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Is it changing one line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    ?

  16. #16
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    thanks jindon again .
    I think your way to calculating is not right as I did it
    textbox5=textbox1-textbox2-textbox3+textbox4

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Then perhaps
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    it's perfect !
    I would add another condition if it's possible.
    sometimes there is name is existed in in SALE sheet but not in BUYING sheet then will value in textbox2 will be minus value , so what I want the value in textbox2 should be positive value if textbox1="-"
    thanks again

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Negative value in TextBox2?

    Impossible for the workbooks uplaoded.

    If you upload a typical sample workbook that creates such issue, it might help.

  20. #20
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Negative value in TextBox2?
    sorry about bad expression !
    I meant when textbox1=- then should change calculation like this
    from

    textobx1-textbox2-textbox3+textbox4
    to
    textobx1+textbox2-textbox3+textbox4
    is it possible?
    another thing should populate names in combobox1 based on BUYING ,SALE sheets.
    Last edited by KalilMe; 05-20-2024 at 09:09 AM.

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    In any situation, no textbox from 1 to 4 will have negative value, since the value in TOTAL rows are all positive.

    Again, it will help if you upload a workbook with such data.

  22. #22
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    In any situation, no textbox from 1 to 4 will have negative value, since the value in TOTAL rows are all positive.
    that's correct usually textbox1 will be bigger than values in others textboxes but if there is no value in txtbox1 then will be minus values in textbox5 example
    textbox1=0
    textbox2=1000
    textbox3=100
    textbox4=10
    textbox5=0-1000-100+10=-1090
    what I want if textbox1=0 then
    textbox5=0+1000-100+100=1000
    In any situation, no textbox from 1 to 4 will have negative value, since the value in TOTAL rows are all positive.
    that doesn't make difference for you because I'm talking about calculation in textbox5 on userform

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Do you mean

    If TB1 - TB2 <0 then (Tb1 - Tb2) * -1 ?
    Or just only when TB1 = 0 ?

  24. #24
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    try
    Please Login or Register  to view this content.
    Last edited by daboho; 05-20-2024 at 10:15 AM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  25. #25
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Try the attached which has no appreciable delay in dispaying the useform.
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Or just only when TB1 = 0 ?
    yes this is what I meant.

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    try change ComboBox1_Change to

    Please Login or Register  to view this content.

  28. #28
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    @daboho
    not really how you calculate ?!
    may you compar with OP,please?

  29. #29
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    try change ComboBox1_Change to
    what about post#17?
    it doesn't calculate correctly if the whole textboxes contains values!

  30. #30
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    how about if textbox2.value = 0 or empty
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by daboho; 05-20-2024 at 10:21 AM.

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    forget about other codes, just follow #27.

  32. #32
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    @JT
    this is strang ! , still slow to open the form, but I think this is not relating slowness with big data because I open the form not select name from combobox to do that yet !
    anyway but the file shows errors calculation !!

  33. #33
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    @daboho
    still shows error in calculation.
    and shouldn't show empty in any textbox. should show zero as hyphen"-"
    how about if textbox2.value = 0
    should change calculation from

    textobx1-textbox2-textbox3+textbox4

    to
    textobx1+textbox2-textbox3+textbox4

  34. #34
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    There are no calculation errors! If you believe so, let me know what they are.

    e,g for "SALE"

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


    = 240,802,865


    which is macro result
    Last edited by JohnTopley; 05-20-2024 at 10:58 AM.

  35. #35
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    forget about other codes, just follow #27.
    still shows error calculation!
    Attached Files Attached Files

  36. #36
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    If one of textbox1 until textbox3 is blank or equal to empty or zero
    The sum will be TextBox1+TextBox2-TextBox3+TextBox4 is correct ?
    If all textbox1 until textbox3 > 0 then
    Result is -textbox1-textbox2-textbox3+Textbox4 is correct ?

  37. #37
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    The sum will be TextBox1+TextBox2-TextBox3+TextBox4 is correct ?
    yes
    f all textbox1 until textbox3 > 0 then
    Result is -textbox1-textbox2-textbox3+Textbox4 is correct ?
    no
    should

    Result is textbox1-textbox2-textbox3+Textbox4

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    You said
    textobx1-textbox2-textbox3+textbox4 (when tb1 is not 0)
    to
    textobx1+textbox2-textbox3+textbox4 (when tb1 = 0)
    When CR-1000 is selected
    TB1 = 2,112.00
    TB1 = 355.00
    TB3 = 44.00
    TB4 = 120.00
    TB1(2,112.00) - TB2(355.00) - TBb3(44.00) + TB4(120.00) = TB5(1,833.00)

    What's wrong?

  39. #39
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    What's wrong?
    When CR-1000 is selected and based on PAID word
    TB1=2,112.00
    TB2=355+210=565
    TB3=44
    TB4=60+120=180
    TB5=2,112.00-565.00-44.00+180.00=1,683.00

  40. #40
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    In "error calculation" file PAID in Sales is 475 not 565
    Attached Images Attached Images

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

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    merge TOTAL row for each sheet based on selected name from combobox on userform
    You must define which row(s) to be added.
    SALE!E11 is blank and VERTING!E3 is also blank.

    There are too many posters here, so I think I'd better step back and see others.

    Please Login or Register  to view this content.
    Last edited by jindon; 05-20-2024 at 11:47 AM.

  42. #42
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    i has cek result in post #30 has correct any blank paid or empty paid in sheets (you can check by sumifs formula)
    only change sum for textbox5
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by daboho; 05-20-2024 at 02:13 PM.

  43. #43
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    thanks JT for spotting my error
    my apologies !
    thank you for your time and you trying to give me better way to solve my requirements .

  44. #44
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    thanks jindon and sorry about my errors.
    everything is ok .

  45. #45
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    391

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    @daboho
    it's great , sorry about my error !
    I wanted show hyphen instead on empty in any textbox.
    any way thank you so much.

  46. #46
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,711

    Re: merge TOTAL row for each sheet based on selected name from combobox on userform

    Thank you for the rep.

+ 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. calculation by userform based on selected combobox to summing or subtraction
    By Mussa-A in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2023, 02:57 AM
  2. [SOLVED] populate sheet based on criteria selected in userform combobox.
    By ANDREAAS in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2019, 04:00 PM
  3. userform merge vaule of combobox and sheet cell value
    By russkris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2016, 03:47 PM
  4. [SOLVED] Combobox - jump to sheet based on selected listindex
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2015, 03:05 AM
  5. [SOLVED] Userform - ListBox items added based on Combobox value selected
    By jayherring86 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-12-2014, 09:12 AM
  6. Unhide sheet based on the combobox value selected
    By irfanparbatani in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2014, 06:25 PM
  7. Update Rows in Database based on Combobox selected item on Userform. Problem .
    By jmarriott in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2013, 01:08 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