+ Reply to Thread
Results 1 to 2 of 2

Calculations/help to create macro button in excel for 2 conditional scenarios

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2003, 2010
    Posts
    1

    Calculations/help to create macro button in excel for 2 conditional scenarios

    MY PREFERENCE IS TO HAVE A MACRO BUTTON [EITHER FORMULA OR VBA] AND HAVE ALL THESE TASKS EMBEDDED IN IT BASED ON THESE CONDITIONS.

    [SAMPLE OF SPREADSHEET]

    MANUF No SUB No. DESCRIPTION ** UNIT QUANTITY
    A1234 94456 TYPE A, XXXX XXX * * * * EA ** * * * 45
    A4235 20374 YA1AM, XXXXXXXXXX * **EA ** * * * 55
    A1482 31375 TYPE B, XXXXXXXXX * * * EA ** * * * 33
    A1461 51725 A1AAM, XXXXXXXXXX * * EA ** * * * 67
    A1356 21873 TYPE A, XXXXXXXXX * * * EA ** * * * 24


    1. CONDITION #1:
    IF "DESCRIPTION" TAB ["C" COLUMN] CONTAINS "TYPE A" AS PART OF TEXT/DESCRIPTION, TAKE THE "QUANTITY" TAB ["E" COLUMN] SPECIFIED ON THAT PARTICULAR ROW AND DIVIDE IT BY 20 & REPLACE PREVIOUS QTY.

    EXAMPLE: IF C2 CELL [TYPE A] WAS CALCULATED:
    • THE QUANTITY IN THAT ROW, E2 [39] WILL BE DIVIDED BY 20
    • AND ROUNDED UP TO THE NEAREST ONE, [39/20=1.95 ROUNDUP TO NEAREST ONE=2]
    • AUTOMATICALLY CHANGE THE ORIGINAL QUANTITY IN E2 BY THE ABOVE ROUNDUP TO “2”.
    • NEED A ONE SHOT DEAL TO AUTOMATICALLY CALCULATE THE CELLS BY CLICKING ON A MACRO BUTTON/FORMULA/CODE [?]


    2. CONDITION #2:
    IF "DESCRIPTION" ["C" COLUMN] CONTAINS "TYPE B" AS PART OF TEXT/DESCRIPTION, TAKE THE "QUANTITY" SPECIFIED ON THAT PARTICULAR ROW ["E" COLUMN] AND DIVIDE IT BY 10, ROUNDED UP TO NEAREST ONE.

    3. AUTOMATICALLY SAVE THE EXCEL FILE AFTER THIS MACRO HAS BEEN UTILIZED.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Calculations/help to create macro button in excel for 2 conditional scenarios

    This is doable and would be far easier if you could provide a sample workbook stripped of sensitive information.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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