First, your asking for a project. Second, your existing code is very inefficient and should have been included IN the file. example selectcase case =”abc”,”def”,”ghi”:cells(1,3).interior.colorindex=6 case else end select == You should provide after examples using cell references.
Don Guillett SalesAid Software dguille...@gmail.com From: Fin Sent: Tuesday, November 01, 2011 5:59 AM To: excel-macros@googlegroups.com Subject: $$Excel-Macros$$ Re: Test Cell String for Element match and report Accuracy Hi Sam, Asa .. thanks for the prompt replies, appreciate it. I have posted a sample file with 100 rows showing sample content. Column L (DAY3) is the target data, Column I (D3_ELE_CNT) contains the number of elements in Column L (DAY3). I have also attached a VBA script file that I generate from REXX and DB2 daily based upon the close of the market. DB2 generates many various CSV report files that I can then open the CSV in Excel, paste in the VBA code and run the macros over as necessary, saving the file as an xls workbook. I posted the REXX script example just to show how I create the VBA code I use at the moment for checking the accuracy of a single element in a cell column. It is derived from a DB2 database and created daily using current stock data to calculate the stock symbol and append a condition of POS/NEG. If I am able to get some VBA code to perform what I have described in my previous post, then I will need to write a similar REXX script to automatically create the new VBA code with current stock conditions on a daily basis to test the various DAY 3 cell strings. So, cell L2 contains the string: [AIG_VNEG]+[GE_VNEG]+[JPM_VNEG]+AXP_NEG+BAC_NEG+JNJ_NEG+T_NEG+TRV_NEG+UTX_NEG+WMT_NEG This is 10 elements as indicated in I2 (D3_ELE_CNT). Based upon the contents of the VBA attached script file, the 3 elements in [ ] brackets were correct and the remaining 7 elements were wrong, so the result would have been as follows: 7,AXP_NEG+BAC_NEG+JNJ_NEG+T_NEG+TRV_NEG+UTX_NEG+WMT_NEG,30% The attached VBA script file contains the individual elements as they closed on 10/31/2011 in the macro titled 'Sub Color_Active_Yellow()'. Presently the macro only contains VPOS/VNEG/PPOS/PNEG variants of the various stocks, but it will also contain POS/NEG variants in due course. If Columns L was individual cells it wold work fine coloring the background Yellow for correct and ACTIVE stocks. I have an ARRAY in REXX of the CLOSE conditions so can write a CASE statement that contains the correct values to test and write that out to VBA code in a text file. What I need, is to be able to read a string of elements and count how many were wrong based on this array, writing the result to Column N, then writing the actual list of wrong elements to column O (Again separated by '+'). I can then calculate the result against column I2 and write an accuracy percentage in say column P using a formula. So in essence I need some kind soul to be able to help me write the VBA code which I will then write into REXX to produce daily. Many thanks again for any assistance. -- FORUM RULES (925+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (925+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com