Is there a way to condense Excel Formula references into one reference while keeping the formula contained to one cell?
For reference the formula I am using is
=VALUE(SUBSTITUTE(RIGHT(G4,LEN(G4)-
MIN(FIND({0,1,2,3,4,5,6,7,8,9},G4&"0123456789"))+1),"-","."))
Which References G4 multiple times, I would like someway to make it so I or another user only has to change G4 in one place should the change be required.
Perhaps something like this (Not real excel formula:)
=MULTIPLEX(VALUE(SUBSTITUTE(RIGHT(#1,LEN(#1)-
MIN(FIND({0,1,2,3,4,5,6,7,8,9},#1&"0123456789"))+1),"-",".")),#1,G4)
So that the #1 does not need to be changed and the G4 being changed once updates the whole formula.
I was trying to avoid VBA so that it is a user friendly formula, I will not be the only one using it.
Side note an implementation of my theoretical multiplex formula would allow for multiple references to be made. Syntax would be like MULTIPLEX([formula],[ref1],[cell1],[ref2],[cell2],...)
Side Side note the Formula is meant to extract the number from an item identifier for sorting purposes. ABC1234-1 becomes 1234.1 so we can sort by number ascending.
Assuming the numeric part is at most 9 characters (including the "-") then you can use this formula to extract, which only references G4 once
=LOOKUP(10^10,SUBSTITUTE(RIGHT(G4,{1,2,3,4,5,6,7,8,9}),"-",".")+0)
Related
I am trying to reference a column in an external Excel document in my formula, and then expanding said formula to the right to auto-fill the remaining cells. I have some values in the formula that I want to not auto-increment, which have been locked using absolute references ($), and others that should increment. But when it comes to the references to the external worksheet columns, those increment even though it makes no sense for them to do so.
Consider this formula as an example, with A1 through A* being a series of dates:
=COUNTIFS(external_sheet[date]; ">="&A1; external_sheet[status]; "ACTIVE";)
If I were to expand this formula to the right, it will increment [date] and [status] to the next column in the sheet. I do not want this behavior, but as far as I can tell there is no way to lock down these values as you can with absolute references. I tried adding a $ symbol before the external sheet reference, but that just breaks the formula.
An option would be to do external_worksheet!$A:$A instead, but for my use case it would make more sense to use references to named columns, as the order of columns may change between data files.
Figured it out after some more Googling (and learning that this is called a "structured reference"). Apparently, the syntax is this:
=COUNTIFS(external_sheet[[date]:[date]]; ">="&A1)
This will make sure that date does not increment to the next column name when filling to the right.
Thanks, I hate it.
With the special character '$' I can prevent an Excel formula from changing its reference when the cell itself is copied (e.g '$A$1').
But is there also a special character that prevents an Excel formula from changing its reference when the referenced cell is moved?
Here's an example:
I have:
Now I move the cells 'A1:A3' down one row. So the formulas in the cells 'C1:C3' change:
But I don't want that the formulas in the cells 'C1:C3' change. They should remain unchanged:
Try formula:
=IF(INDEX(A:A,ROW(1:1))=INDEX(B:B,ROW(1:1)),"Same","Not same")
the formula always work, regardless of any column been delete besides columns A or B
If you always want to refer to A1, then you can't just use A1 as a reference, because, as you have seen, Excel will adjust that reference if rows are inserted above.
Instead, use Index(A:A,1) . That will always return the value from the first row of column A.
=if(index(A:A,1)=index(B:B,1),"same","not")
Edit after comment: If this does not suit your purpose, maybe you need to redesign your spreadsheet so that the position of things does not change all the time. This looks like you are adding new data at the top of a list.
Excel works from top to bottom and things will be a lot easier if new data is added at the bottom of a list. You can always use other Excel tools to change the sort order if you want to have the data sorted in reverse chronological order.
Use formula in C1:
=IF(INDEX(A:A,ROW(ZZ1))=INDEX(B:B,ROW(ZZ1)),"Same","Not same")
and copy down.
=INDEX($AT$1:$AY$66,MATCH("REGULAR PAY *",$AT$1:$AT$66,0),3)
Because I use this same array value ($AT$1:$AY$66) in multiple formulas across the sheet (and it could change at some point) it would be nice if I could put $AT$1:$AY$66 into a cell and reference it within this formula. So far I haven't had any luck being able to do that.
I've managed to get past this now by using INDIRECT(BF7) in place of my AT1:AY66 where BF7 is where I have AT1:AY66. Now if it happens that I need to change that array to AT1:AY70 for example I can just change it in BF7 and it will alter all my formulas accordingly.
I'm using the INDIRECT function to fetch data from another table sheet.
The direct way would be "sheetname!A5". I need it dynamically, so the sheetname is also part of the table, using indirect "indirect("'"&G$1&"'!A5"), whereas G1 contains the sheetname works fine.
INDIRECT is horribly slow, which outperform my project because I need a lot of fetches.
Is there a less powerful / more performant function to fetch data from variable sheets?
I've run into similar situations - depending on how frequently your 'results' worksheet changes, it may be best to create a formula dynamically that initially 'writes' hardcoded formuls. For example: ="='"&G$1&"'!A5".
Then copy that formula as you wish; it will create text strings that represent what you want the formulas to look like. Then copy & paste as values - you will now have the desired formula entered into each cell. By default, Excel will still display each cell as a text string, even though the format type would be general (assuming it was beforehand). From there, different solutions are possible - if you have few enough cells it may be enough to just start at the top pressing F2 then Enter, repeatedly, to get Excel to calculate each cell.
This seems like such an obvious thing that excel must have this feature, I just can't find it.
How can I create a custom function without using VBA? (VBA is too big of a hammer and causes security warnings, etc).
For example, I have a spreadsheet with several very complex formulas. Each of these formulas are replicated in several columns. Each column has hundreds of entries, so each one is replicated hundreds of times. If I tweak something then I have to manually fill-down or copy my change from one column to another.
A simple one looks like this:
=(Payment1 - F$12)*12 + ($D21-H21)
But what I'd like to do is:
=MyFunction(f$12,$D21,H21)
And have the actual formula for "MyFunction" written just once someplace.
I've found a few things that come close to giving me what I want. For example, in tables Excel will automatically replicate changes in a formula down the rest of the column saving you the step of manually selecting the range and doing a "Fill Down".
It will also allow relative references off of named cells, which seems equivalent of a user-defined parameter-less functions.
if you can use text to create the formula, then you can define a name to evaluate the function.
In cell A2, create a name EvalAbove, and in Refers To, enter =evaluate(A1)
This way, you can construct a formula
e.g. B1 contains SUM, B2 contains =("="&B1&"(A2:A5)")
and in B3, you can then put =EvalAbove
This means that if you change the formula name in B1, then B2 will change to show the changed formula, and B3 will change to show the result.
Note that this still counts as a macro enabled workbook, but there's no VBA code, just named ranges
You can do this for the example you show if I interpret it correctly.
If not you may be able to rearrange things slightly to conform
your function has three parameters:
The first comes from row 12 of the current column
The second from column D of the current row
The third comes from the column two to the right of the current row
I assume Payment1 is a named variable already?
Set the cursor in say F21 and then define this name
MyFunction =(Payment1 - F$12)*12 + ($D21-H21)
This will set the parameters to come from the places shown
To understand this better switch to RC mode and type the formula as:
=(Payment1 - R12C)*12 + (RC4-RC[+2])
You can now propagate down the formula through the F coloumn
=MyFunction
and it will always use the values in the corresponding F12 column Dxx and column Hxx
If you drag the formula to the next column it will use G12, Dxx and Ixx
If you want to change the formula edit it in the define name space
This is a general exception to the rule that you cannot have non-vba UDFs in Excel. Often in Excel the things you want as 'arguments' to the function are actually in fixed places (rows or columns) that can be addressed relatively.
For example you often want to perform a udf on the cell to the left
So a udf giving the cuberoot of the cell to the left would be a named formula like this:
Cuberoot =(RC[-1])^(1/3)
Or in a1 form set the cursor in B1 and type =(A1)^(1/3)
And Excel will convert it internally to the RC form
For three args - use three columns
It works and does not suffer the volatility issue mentioned about evaluate()
Yes I know this is an old posting but it may help someone with the same issue.
Bob J.