1

I could probably puzzle this one out in VBA, but would rather not have to use that approach if possible, and it seems like this is something Excel's built-in functions should be able to manage.

I have a spreadsheet we recently stopped printing that we would use to verify data came in from our various sites, and for which days. Column headers correspond to site numbers ($D$1:$AU$1 for this spreadsheet) and rows are for dates ($A$3:$A$24 for the month of December -- we don't do this data validation on weekends). The "B" column contains the date whose information SHOULD have come in, for example, on 12/4, we should receive the information from 12/2 at each site.

In the past, we used column "C" to write which sites were behind. If Site 3 only sent in information from 12/1 on the 4th, we would write a "3" in that column. I'd like to continue this convention, since it's what the office understands. Change Is Bad and all that.

So far I've muddled through on my own and wrote an Array Formula that returns {0,0,1,0,...,0} if only site 3 is behind. That formula is =IFERROR(SEARCH(B3,D3:AU3)-SEARCH(B3,D3:AU3),1)

From here it's trivial to do =IF(ISBLANK(D4),"",INDEX(D1:AU1,1,MATCH(1,IFERROR(SEARCH(B3,D3:AU3)-SEARCH(B3,D3:AU3),1)),0)) which works great, so long as there's only one site that's behind. If we have more than one site behind, it returns the first value (as expected).

If both sites 3 and 6 are behind, we want to see "3, 6" (or any other human-readable format) but the only solutions I found are to write a custom VBA script to concat an array. I'd rather stay away from custom VBA if humanly possible.

Thanks,
Adam

7
  • VBA might be best - there's no inbuilt worksheet function in excel that can concatenate an array - you could write a formula that would get 3 in one cell then 6 in another etc. would that help? Dec 2, 2013 at 19:10
  • Not sure it would, since the number of sites that are "behind" could be zero one day and twelve the next. It's hard to account for variable columns in that way.
    – Adam Smith
    Dec 2, 2013 at 19:19
  • If you have the columns available you can write a formula that you can copy across 5 or 10 or 15 rows, as many as the maximum you might need - if there are no matches all the columns will display as blanks but if there are 7 behind or 1 you will get just those 7 or 1 Dec 2, 2013 at 19:22
  • You are using SEARCH in SEARCH(B3,D3:AU3) - use of SEARCH implies that B3 isn't an exact match - is that right? - if B3 contains a date don't you just expect an exact match somewhere in D3:AU3 (I.e. the same date?) Dec 2, 2013 at 19:24
  • I may be able to add hidden columns after the data to pull that info to, then =TRIM(CONCATENATE(<each>," ",<of>," ",<them>)) that way. That might help....
    – Adam Smith
    Dec 2, 2013 at 19:25

1 Answer 1

2

Try this "array formula" in BA3

=IFERROR(INDEX($D1:$AU1,SMALL(IF(ISERROR(SEARCH($B3,$D3:$AU3)),COLUMN($D3:$AU3)-COLUMN($D3)+1),COLUMNS($BA3:BA3))),"")

confirm with CTRL+SHIFT+ENTER and copy across to get all matches

As you say you can then concatenate those back to C3

3
  • This is working as intended, but only filters based on sites that DO have their data in on time. We're looking for the #VALUE! response from the SEARCH array.
    – Adam Smith
    Dec 2, 2013 at 19:40
  • D'oh!, yeah, I knew that but forgot......just change ISNUMBER in the middle to ISERROR (Note: not IFERROR) - I'll edit my answer Dec 2, 2013 at 19:50
  • Perfect! I came up with my own solution in the meantime but this one is much prettier. I simply used =IF(IFERROR(SEARCH($B$4,D4:AU4)-SEARCH($B$4,D4:AU4),D1)=0,"",D1) and autofilled one column for each site, then `=TRIM(CONCATENATE(BA3," ",BB3," ",BC3," ",...," ",CM3) IN B3. Truly great work there, and I greatly appreciate it!
    – Adam Smith
    Dec 2, 2013 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.