Most efficient way to place hundreds of array formulas? - excel

I am new to VBA and advanced formulas for that matter and would deeply appreciate some guidance here.
I have a workbook that acts as a GUI for a database in another workbook. I use the following array formula to act as a search function:
{=IF(ISERROR(INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)),ROW(1:1)),2)),"",INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)-1),ROW(1:1)),1))}
Although very sloppy, this works fine. However, I now need to add option buttons to toggle between searching for two different things. This means I have to replace the array formula from A3:L104 through VBA. My question is twofold:
How can I shorten this formula to under 255 chars to use with .FormulaArray? I tried putting it in two halves but my understanding of syntax is not sufficient.
Even if I got that to work, I imagine it would be extremely slow and inefficient. Is there a better way to go about this task?
Any help is greatly appreciated, I'm in way over my head with this. Thanks in advance.

First off, swap out your IF(ISERROR(<formula>), "", <formula>) for something that uses the IFERROR function. This will effectively cut your formula in half as IFERROR takes care of error control and default value without duplicating the formula.
=iferror(INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)-1),ROW(1:1)),1), "")
I did not build all of the external references and named ranges for a full build environment, but I believe I transcribed that correctly.

Related

How can I run a vlookup on vba array

Fairly new to posting here but not new to the site.
I have done a fair bit of Googling on this one but still don’t seem to have the answer so thought I’d post here.
This is high level and no code included just now although can provide later.
I have a template that is completed by customers and within that template are hidden tabs, one of which has a table that is used as part of a vlookup.
What I am trying to achieve here is to read the customers submitted data into account of an array (done) and then do some kind of equivalent to a vlookup on a column in the array and then add the results to a new column in the array.
I’m happy to also read the lookup table into an array or dictionary as I understand this is a far better approach.
I’m just stuck on what to use instead of vlookup and how to achieve the above.
Any thoughts would be appreciated. Thanks in advance.

Filling data via series AutoFill without dragging

It's been quite some time since I used a spreadsheet product. In Excel 2003 there was a series autofill feature. I don't mean the "enter two numbers, highlight, and drag" feature. There was a way to bring up a menu, alt-e-i-s if my muscle memory recalls correctly, that would let you specify a start value, end value and step value. It was incredibly useful.
I really could use this feature in Google sheets. I've been searching for the last 15 minutes and can not find it anywhere. I also checked and it looks like this might not be a feature in MS excel anymore, either. Does anyone know if either product can do this?
You are probably looking for the SEQUENCE function in Google Sheets
=SEQUENCE(11,1,6,2)
Please read more about it here

List all functions that are called in Excel

Does anyone have a quick way/macro that lists all the functions that are used/referenced in an Excel sheet/worckbook ? Including addin functions (example : C#/C++ addin functions ).
Or, alternatively, a method that tells if a certain input function-name is called.
[Mods - feel free to delete this answer as it's essentially link-only. Perhaps I should know better, but I think this could be helpful to the OP]
I have a solution to this but it's proprietary so I can't release the source. However I'll describe the approach. It's not a quick way!
It's not easy to formulate a tokeniser for the Excel formula grammar. For one thing, you don't know the formula list in advance so you can't hard-wire them into the grammar. But the form of a formula in Excel is sufficiently well-defined to be able to tokenise it in a reasonably systematic manner.
Take a look at http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html. This shows you how to tokenise an excel formula. Once you have a formula tokenised, you can extract the function names.

how to display data that is related to a specific cell in excel 2010?

I have created 2 columns, the first has a category of a system using data validation, and the second has the description and failures of that system.
The purpose of that is to open a malfunction on some parts.
In a different sheet I wish to do the same only this time I want to choose the system and the description will automatically appear in the next column showing me all the malfunctions I have written on this system.
I am not very good at all the functions of excel. but I still searched for one that might help me. I have tried using the DGET function but it got me nowhere.
Perhaps try the solution here - it's a bit tricky to explain without copy-pasting the whole thing:
https://superuser.com/questions/536234/excel-how-to-vlookup-to-return-multiple-values
Also take a look at vlookup() if you're working across spreadsheets.
As expected, all of the responses you've seen ehere - and probably elsewhere - are ponyers to VLookup, or a refusal to answer your question.
I'm guessing that you're using DGET() because you need to retrieve data from one named column, using a match for a search term in another named column; and you're that because you can't rely on column ordinals or addresses - you have to do it by name.
VLookup won't do that for you: not without extremely complex and fragile array formulae.
The bad news is: Microsoft NEVER published a working example of a DGET() formula or any corresponding VBA Worksheet Function code.
There's page after page of descriptive text and general explanation in the helpfiles and on MSDN: but no working example. Nobody in Redmond ever sat down and made the DGET() function work with a reproducible set of function parameters and published a screen-shot the working formula.
I'll let you guess why that is.
Maybe there's an example somewhere that is, in effect, a VLookup implemented for known column ordinals using DGET(). If there is, I never found it and you won't either: and it would, of course, be useless for any application where you're working with field names instead of known ordinals.
What you need to do is capture the tabulated data range, with field names in the top row, and pass it to a SQL query using ADODB or MS-Query. That bad new for that is that all the MS-JET Excel drivers have a fatal memory leak.
After that fails, you're left exporting the data somewhere that a proper database app can run the SQL: and that's actually the right thing to do, because your attempt at using DGET() is a relational data query.
If you're left with the need to do this entirely in Excel, you have reached a level of desperation normally associated with the last survivor of an airplane crash who, having devoured the charred remains of his unlucky fellow passengers, is finally forced to contemplate the awful exigency of opening and eating the inflight catering meals.
The grisly details for the equivalent in Excel are a Horrible Hack published here:
http://excellerando.blogspot.com/2014/09/from-time-to-time-it-necessary-to.html

Collect Data from two fields, to input into a complete list

I have been working on this document, I have been going to YouTube to learn how to do some of these things for myself. I hate asking for help because sometimes I never learn how to do things myself.
So I am looking at this one script in "lesson" 358, the concept of the lesson is to make it so that the script references one point of reference to get the information in question.
http://www.youtube.com/watch?v=Tp7I5...feature=relmfu
The problem with this video is that although it is well done he really isn't referencing one field. He is using multiple fields and calling it one reference point.
That is the video, here is the attachment document to the video is here.
Download Excel Sheet from Video
What I wanted to do was to have it so the script only reference one point of interest, so I emailed the creator of the script, and he told me that he can't help. Sounds more like he didn't want to help...
Here is my file, What I am attempting to do is this:
My Excel Sheet
In AH1 I have a date, that I am using as the reference point for the entire formula that I thought I could use.
And have done so successfully in the AJ2 Script...
What I wanted to do is to make my document utilize the script in the lesson above but with one reference point instead of two in AK2 downwards... The list it is pulling data from in this case is Topic1.
What ends up happening is that I try to cut out the reference point is it tells me that there are too few references and won't let me save the script.
I have attempted several times to get this working, but for some reason it's causing me issues, well that seems to be nothing new.
And if the creator of the script can't help me, I know I'm not going to be able to do it myself, even though I've spend the last two days trying...
Can someone help me here please?
1) Fix AH1. Just put in the formula =TODAY() and then format the cell the same way you formatted cell AA4.
2) Fix AJ2. The formula should be: =COUNTIF(AA4:AA23,AH1)
3) Fix AK2. The array formula should be:
=IF(ROW($A1)>$AJ$2, "", INDEX(AB$1:AB$23, SMALL(IF(AA$1:AA$23=Criteria, ROW($AA$1:$AA$23), ""), ROW($A1))))
...confirmed by pressing CTRL-SHIFT-ENTER, then copy that cell down a ways, multiple values can appear now if needed.

Resources