colors Posted May 23, 2012 Share Posted May 23, 2012 After starting my previous thread "What formula will work to acieve this result" I decided to post this new thread because I have changed my mind and will now be using the external Excel file that the "Extract Data" creates to do my calculations. Here's what I would like to do: create a Macro [button] in Excel with the following conditions: * Sample of excel 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, ROUNDED UP TO NEAREST ONE.* 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. I will really appreciate a Speedy solution....soon Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 23, 2012 Share Posted May 23, 2012 Something like this? =IF(ISNUMBER(FIND("TYPE A", C1)), ROUND(E1, 2), "") Quote Link to comment Share on other sites More sharing options...
colors Posted May 24, 2012 Author Share Posted May 24, 2012 Thank you for your help Mircea. I tried pasting that code in excel [right clicking on an object, assign macro] but it gives me an error [Microsoft Visual Basic...Compile error: Expected: line number or label or statement or end of statement]. I don't know if I did this correctly as this is my first time working on codes. Can you please guide me thru'? FYI, in your new code please note that the "Description" starts from row C2 onwards and the "Quantity" starts from E2 onwards which is the one to divide by either 20 or 10 [per conditions I specified at the start of this thread], rounded by nearest one and replaced in the "Quantity" column/row for that particular condition. I was trying to attach the excel file or gif file to give you a better picture of the scenario but was not successful. Regards, Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 24, 2012 Share Posted May 24, 2012 My example is to be used as a cell formula; I'm afraid that you didn't stated that you were looking for a VBA example. Quote Link to comment Share on other sites More sharing options...
colors Posted May 24, 2012 Author Share Posted May 24, 2012 (edited) Sorry about that. Would VBA be better in automating the series of these tasks? If so, please provide a solution [i don't mind either one is fine as long as it works] based on the criteria I have provided above. My preferance is to have a Macro button and have all these tasks embedded in it. Please note that I donot require the roundup as the quantity has already been set to roundup in the AutoCAD Table. Thank you. Edited May 24, 2012 by colors Forgot to mention about not needing "roundup" in the formula/code Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.