+ Reply to Thread
Results 1 to 7 of 7

modifying code calculation unit price on userform

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

    Angry modifying code calculation unit price on userform

    Hi guys ,
    I have code to calculate stock across sheets on form.
    now I add two TOTAL columns(I,J) in STA sheet and others sheets keep the same structure
    , what I want sum and subtract TOTAL columns across sheets.

    the sheets should be =STA+RPA-SS (COLUMNS =TOTAL(I+H-H)) and divide result on QTY for column (10) in listbox
    and Sheets should be =STA+SR-RR(COLUMNS =TOTAL(J+H-H)) and divide result on QTY for column (10) in listbox
    ex: FR-1 ID= (2000+1200+1300)-(60+220)=4260 / 379=11.24010554 as show in column 11 in listbox
    FR-1 ID=(3000+75)-(30+30)=3015/379 as show in column 12 .
    result as the picture in last sheet when there is no selected sheet from combobox1.
    as to when select sheet name then just

    to reminding what code really does it.
    I have many sheets about five sheets contains data are almost 3000 rows for each sheet and it will increase continuously . so what I want when run the userform should merge the duplicate items based on COL B across the sheets each sheet repeat the items except the first sheet because this data collected from previous year. the others sheets are current year operations with considering the second sheet sometimes contains new item then should show in listbox . after merge duplicate items should show the QTY for each sheet . about COL 11 in list box and calculate like this as item (FR1)=200+200-5+4-20=379
    as columns 11,12 in list box will calculate price average as I mentioned above
    column 13 in list box =columns(12-11)* column(10).
    as to selected sheet from combo box should follow the same way when calculation the price average when there is duplicates ID in each sheet alone without calculation across sheets.
    the ID is not necessary to be existed in all sheets , sometimes there are new IDs in sheet and not existed in other sheets.


    thanks
    Attached Files Attached Files

  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
    30,925

    Re: modifying code calculation unit price on userform

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JohnTopley; 04-18-2025 at 09:37 AM.
    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
    409

    Re: modifying code calculation unit price on userform

    Thanks john for your effort.
    also I would calculate average price and merge ID when select specific sheet and cancel date column by replace with item 1,2,3... , I would arrange columns width when select sheet name because I see to there is big space before last column .
    question : the last sheet is helper so I can't delete? if it's so the macro do all of thing without I should do anything about data?

  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
    30,925

    Re: modifying code calculation unit price on userform

    also I would calculate average price and merge ID when select specific sheet and cancel date column by replace with item 1,2,3.
    ... was not asked for so I'll leave this to others as it is completely new code: current code simply copies sheet data to listbox. Not even a "please"!

    And you will need to provide sample of expected output.

    the new macro does "arrange columns width" but Excel appears to fit the last column to listbox width so I amended Listbox width for individual sheets to remove the big space.

    Last sheet can be deleted as it is not used by macro.
    Attached Files Attached Files
    Last edited by JohnTopley; 04-18-2025 at 02:25 PM.

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

    Re: modifying code calculation unit price on userform

    ... was not asked for so I'll leave this to others as it is completely new code: current code simply copies sheet data to listbox. Not even a "please"!
    but I mentioned so
    as to selected sheet from combo box should follow the same way when calculation the price average when there is duplicates ID in each sheet alone ...
    Last sheet can be deleted as it is not used by macro.
    but you use in your code !
    Please Login or Register  to view this content.
    so will show subscript out of range when delete it.

  6. #6
    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
    30,925

    Re: modifying code calculation unit price on userform

    Sorry ... forgot to delete the code ...
    Attached Files Attached Files

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

    Re: modifying code calculation unit price on userform

    thanks again.
    I hope to check my last comment about average price for each sheet alone & merge duplicates ID when select when sheet from combobox.

+ 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] Split shipping costs per unit + add it to unit price
    By N7000 in forum Excel General
    Replies: 15
    Last Post: 05-09-2023, 04:42 AM
  2. Unit Price Calculation
    By asifprpt900 in forum Excel General
    Replies: 12
    Last Post: 01-05-2023, 08:05 AM
  3. Unit Price Matching Material Code and UOM
    By bj90 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2019, 04:10 PM
  4. [SOLVED] Calculation for unit price , quentity , discount and final TOTAL
    By Infas in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-03-2015, 11:17 AM
  5. Replies: 3
    Last Post: 01-03-2013, 12:32 AM
  6. Replies: 4
    Last Post: 08-15-2012, 09:49 AM
  7. Automatic calculation of cheapest unit price with bulk discounts
    By whirlwind1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-18-2011, 08:20 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