0

I have a sheet in a workbook called lookup. Here, users can enter a department code in cell B2 and click a "Search" button which will lead them to a sheet called deptlookup. deptlookup will list all account codes that have the dept code the user entered inside of it in column A and the account code description in column B. Account codes look like ####### - ### - ## - ###### (bold section is where department code lives in the account code). The formula in column B is working fine, but the formula in column A is not. It is yielding account codes that have different department codes than what the user is searching for. Formulas:

in cell A2: =IF(lookup!B2="","",lookup!B2) (gets dept code).

In cell A3: =COUNTIFS(acct_codes!A:A,"*-"&A$2&"-*") the account codes are located in a sheet called acct_codes a dynamic query refreshes and pulls active acct_codes from a database.

in cell A4: (starting the list of acct_codes) =IF(ROWS($A$4:A4)>A$3,"",INDEX(acct_codes!$A:$A,SMALL(IF(ISNUMBER(SEARCH("-"&A$2&"-",acct_codes!$A:$A)),ROW(acct_codes!$A:$A)-ROW(acct_codes!$A$2)+1),ROWS($A$4:A4)))) -- doesn't display an account w/ the department code the user searched for.

in cell A5: {=IF(ROWS($A$4:A4)>A$3,"",INDEX(acct_codes!$A:$A,SMALL(IF(ISNUMBER(SEARCH("-"&A$2&"-",acct_codes!$A:$A)),ROW(acct_codes!$A:$A)-ROW(acct_codes!$A$2)+1),ROWS($A$4:A4))))} Does display account code with department code user searched for.

in cell A6: {=IF(ROWS($A$4:A5)>A$3,"",INDEX(acct_codes!$A:$A,SMALL(IF(ISNUMBER(SEARCH("-"&A$2&"-",acct_codes!$A:$A)),ROW(acct_codes!$A:$A)-ROW(acct_codes!$A$2)+1),ROWS($A$4:A5))))} (DOES NOT display account with department code being searched for)

in cell A7: {=IF(ROWS($A$4:A7)>A$3,"",INDEX(acct_codes!$A:$A,SMALL(IF(ISNUMBER(SEARCH("-"&A$2&"-",acct_codes!$A:$A)),ROW(acct_codes!$A:$A)-ROW(acct_codes!$A$2)+1),ROWS($A$4:A7))))} --does display account code with department code user searched for

AND SO ON..

Does anyone know what I am doing wrong? Or have any suggestions/alteration I can make to this formula?

4
  • Are all of your cells not working? A1: seems ok to me; A2: might have to change the first * to ??????? (as there are two parts where the * might work), leave the second *. A3-A5 I'll have to dig in more to figure out the formula
    – gns100
    Sep 19, 2017 at 18:52
  • @gns100 I used these formulas before except, the acct_codes!A:A was specified as a specific range: acct_codes!A2:A206811 with this go-around, the account codes in the acct_code sheet is a dynamic query so, idk how long the range will be at any given time, that's why I've tried to go with the acct_codes!A:A approach in these equations. Being that the range is larger, A2 looks fine, SO does A3, I believe. Once it gets down to where the account codes are being listed, starting from cell A4 and onward, that is giving me issues. Thanks for any help you can provide.
    – anve
    Sep 19, 2017 at 19:11
  • My original answers, A1 should have been A2, and A2 should have been A3
    – gns100
    Sep 20, 2017 at 0:00
  • I'm not sure I'll be much more help, those array formulas are not my strong point. I'm guessing it's trying to create a list of orgs with no space between rows (or some similar google query I did years ago).
    – gns100
    Sep 20, 2017 at 0:03

0

You must log in to answer this question.