Is it possible to use a Concatenate formula (or using &) inside an Excel shape?
So I understand you can link a cell inside an Excel shape (e.g. =A1) but is it possible to write ="Total YTD "&A1 (if A1 is a total #) or =CONCATENATE("Total YTD ",A1)
When I try to do this, it gives me the error "This formula is missing a range reference or a defined name"
Have you tried doing the formula work in one cell and then referencing the cell?
It is indirect, but it overcomes the apparent limitation of the shape object. It will also let you use special characters like &Char(13) to generate carriage returns in the text box as well.
An alternate means may be to copy a cell containing the formula and pasting it as a linked picture. With this it will allow you to effect the object with conditional formatting.
Related
I have created an expression using "&" to concatenate different cells, I created this:
=INDEX((Data_sheet!A1:M20440;Data_sheet!A20441:M40880;Data_sheet!A40881:M61320);20;5;D2)
Now, I have the expression that is a formula, but it is not evaluated as a formula when I paste it, I can see the whole expression in the cell, but I want to get is the value that is behind evaluating that formula. I want to know how to make it to evaluate as a formula (because I will have thousands of this expressions)
My guess is that you would have created the INDEX formula in excel using multiple other formulas.
Once you have created the formulas, copy all the formulas and paste it in a txt file. Then, copy all the formulas from txt file and paste it again in the excel where you want the formulas to perform. This is the simplest way of doing this without creating any macros or additional formulas
See this question for solutions:
How to turn a string formula into a "real" formula
In particular, also note the answer about Excel's hidden EVALUATE function, that can only be accessed after defining a name to use it.
https://www.vertex42.com/ExcelArticles/evaluate-function.html
I have a cell number as a string ("A1") in a formula, and this needs to be changed relatively while copying, like it does automatically to normal cell references. so I don't have to visit 400 cells and change them all by hand.
Any way I can manage this? Thanks for the help.
Formula I am using in 400 cells:
=IF(IDENTIC($M$10;"Entries are correct.");IF(ISNUMBER(FIND("A1";$N$5));"S1";IF(ISNUMBER(FIND("A1";$N$6));"S2";IF(ISNUMBER(FIND("A1";$N$7));"S3";IF(ISNUMBER(FIND("A";$N$8));"S4";IF(ISNUMBER(FINDEN("A1";$N$9));"S5";"")))));"")
I don't want to change every single cell as text in all 400 cells, it should change relatively as normal cell references do.
To get a cell reference as a string in Excel you can use the CELL function:
=CELL("address";A1)
Since the second parameter to the function is an actual cell reference, if you copy and paste this formula it will auto-update accordingly.
Bear in mind this will return a string containing an absolute address so it will return "$A$1", not "A1".
CELL(...) will work.
More generally, you can also build the formula as strings using concatenations. This can be useful when you have a list of stuff and you would like to have formulas that refer to those names. Or in your case it would also work.
Building the formula as string with concats & then search & replace
First I build up as much as I can the formula so that the general structure is already formed (only the reference you'll want to change will not be final):
Using your case as an example:
Then, I wrap that nearly-formed formula into a CONCATENATE(). I then arrange things to have a references that I will point to within that CONCAT() that will auto-increment to the text I actually want to include in my formula. Something like this:
=CONCATENATE("IF(FIND(""",A1,"""$A$4),TRUE, FALSE)")
The ,A1, refers to the actual cell, so that cell's content is what will be included in my formula. You can then increment this all the way to build the proper formula for each cell (the 400 ones in your case). You need the triple """ because you want to actually include A1, B1 etc... are text references, not cells.
Then, all you need to do is selected all those formulas, copy them & make sure to choose past as values, say the line under (to keep you concatenate intact so you can edit it later if needed). Then with that pasted line all selected, you use a find & replace to add an "=" sign to the beginning of formulas. Better be too specific on the find & replace, so find "IF(F" and replace by "=IF(F" or similar. Then magic happens:
You can see that A1, C1, D1 have returned TRUE while the rest are #VALUE! because the find method has failed to find the string.
I have the following array formula in cell B2 in my Excel spreadsheet:
={IF(COUNT(IF(ISNUMBER(A30:A1000);IF(C30:C1000>A30:A1000-1;A30:A1000)))>=COUNT(IF(ISNUMBER(A30:A1000);IF(B30:B1000>A30:A1000-1;A30:A1000)));COUNT(IF(ISNUMBER(A30:A1000);IF(C30:C1000>A30:A1000-1;A30:A1000)));IF(COUNT(IF(ISNUMBER(A30:A1000);IF(C30:C1000>A30:A1000-1;A30:A1000)))<=COUNT(IF(ISNUMBER(A30:A1000);IF(B30:B1000>A30:A1000-1;A30:A1000)));COUNT(IF(ISNUMBER(A30:A1000);IF(B30:B1000>A30:A1000-1;A30:A1000)));COUNT(IF(ISNUMBER(A30:A1000);IF(C30:C1000>A30:A1000-1;A30:A1000)))))}
Now I want to use the following VBA code to copy this code into cell A2:
Sheets("Sheet1").Range("A2").FormulaArray = Sheets("Sheet1").Range("B2").Formula
However, when I use this code I get runtime error 1004.
Do you have any idea how to solve this issue?
character limit of 255 when passing arrays...
https://support.microsoft.com/en-us/kb/213181
Set up named ranges for a30:A1000 of A, B30:B1000 of B, and c30:c1000 of D (C is reserved so you can't use it and CC will make this formula too long also) (ctrl+f3 to open the named range manager and then hit new button)
Then Change your formula to use the named ranges.
=IF(COUNT(IF(ISNUMBER(A),IF(D>A-1,A)))>=COUNT(IF(ISNUMBER(A),IF(B>A-1,A))),COUNT(IF(ISNUMBER(A),IF(D>A-1,A))),IF(COUNT(IF(ISNUMBER(A),IF(D>A-1,A)))<=COUNT(IF(ISNUMBER(A),IF(B>A-1,A))),COUNT(IF(ISNUMBER(A),IF(B>A-1,A))),COUNT(IF(ISNUMBER(A),IF(D>A-1,A)))))
Alternately you could set up custom VBA functions that would allow you to replace the repetitive code within your if statement with shorter strings of characters to bring you under the 255. But ultimately you need to get under 255. Once under 255 your code works fine, either with my changes above or with a shorter array formula. (note that I changed the semi-colons to commas so you might need to change them back if you use semi-colons)
I believe the issue lies with the references within the formula. As the cell B2 references A30:A1000 in the formula, when you apply this to the cell A2 it tries to move the reference one column to the left - which it can't. In order to bypass this you can make the references absolute:
={IF(COUNT(IF(ISNUMBER($A$30:$A$1000);IF($C$30:$C$1000>$A$30:$A$1000-1;$A$30:$A$1000)))>=COUNT(IF(ISNUMBER($A$30:$A$1000);IF($B$30:$B$1000>$A$30:$A$1000-1;$A$30:$A$1000)));COUNT(IF(ISNUMBER($A$30:$A$1000);IF($C$30:$C$1000>$A$30:$A$1000-1;$A$30:$A$1000)));IF(COUNT(IF(ISNUMBER($A$30:$A$1000);IF($C$30:$C$1000>$A$30:$A$1000-1;$A$30:$A$1000)))<=COUNT(IF(ISNUMBER($A$30:$A1000);IF(B30:B1000>A30:A$1000-1;$A$30:$A$1000)));COUNT(IF(ISNUMBER($A$30:$A$1000);IF($B$30:$B$1000>$A$30:$A$1000-1;$A$30:$A$1000)));COUNT(IF(ISNUMBER($A$30:$A$1000);IF($C$30:$C$1000>$A$30:$A$1000-1;$A$30:$A$1000)))))}
I have to restrict some invalid data in a Excel Column.
Below is Validation Criteria:
Should be a numeric Number
Size/Length should be equals to 9
Ex : valid:602005514, invalid:were,43456 etc.
I have created a Custom Data Validation using below function.
=AND(LEN(INDIRECT(SUBSTITUTE(ADDRESS(ROW(),COLUMN()),"$","")))=9,
ISNUMBER(INDIRECT(SUBSTITUTE(ADDRESS(ROW(),COLUMN()),"$",""))))
//here i have to get cell name dynamically. so, i have used ADDRESS function
But its not working as expected. It is not allowing any value in cell.
I guess it might be because of LEN function circular reference.
I have tried many ways, but not able to solve it. Please help me to solve this.
You don't need to resort to INDIRECT etc, in you formula just refer to top left cell in the range you are applying the validation.to. Excel will adjust for the othger cells in the range. When entering cell references don't use absolute references, ie no $'s
Eg select a range starting at cell A1, and set data validation formula to
=AND(ISNUMBER(A1),LEN(A1)=9)
Check this simple validation .. checking Cell D13 ..
=IF(LEN(D13)=9,IF(ISNUMBER(D13),"yes","no"),"no")
Another way:
=AND(ISNUMBER(A1),A1>99999999)
Make sure there are no leading or trailing spaces in the cell:
=IF(TRIM(A3)=A3,TRUE,FALSE)
How does one cell obtain the formula of another cell as text without using VBA? I can see this question has already been asked many times and the answer is always to write a custom function in VBA.
However, I found a post made in 2006 which claimed to have found the non-VBA solution but the link provided in that post is already broken.
=FormulaText(Reference) will do the trick Documentation
There is nice way of doing this without VBA. It uses XL4 macros (these are macros, but it is not VBA, as asked).
With reference to the figure 1, cells A2:A4 contain usual formulas.
Going to Formulas -> Define Name, I defined two named ranges (see fig. 2), with the information shown in cells A6:B8.
Enter in cell B2 =FormulaAsText. This will retrieve the formula in cell A2 as text.
Explanation:
The named range FormulaAsText uses =GET.CELL(info_type,reference). In this case, ìnfo_type = 6 retrieves the formula, and reference = OFFSET(INDIRECT("RC",FALSE),0,-1) uses the cell with 0 rows and -1 columns offset from the one the formula is used in.
Copy B2 and paste into B3:B4. This will show formulas in A3:A4. Cell A4 shows that the worksheet function CELL only retrieves values, not formulas (as opposed to GET.CELL).
Since FormulaAsText gets the formula from a cell at fixed offset (0,-1) from the current, I defined another range FormulaAsText2, which uses an offset (rows,cols) read from the worksheet itself. Cells D2:D4 contain =FormulaAsText2. Thus, cell D2 shows the contents of cell B3 (=OffSET(D2,1,-2)), which is FormulaAsText. cells D3:D4 show the contents of themselves. This adds some flexibility. YMMV.
PS1: The essence was taken from
http://www.mrexcel.com/forum/excel-questions/20611-info-only-get-cell-arguments.html
PS2: Tim Williams mentioned in a comment "the old XLM GET.FORMULA()". This answer is possibly related (not the same, since this one uses GET.CELL()).
PS3: A simple VBA solution is given, e.g., in
http://dmcritchie.mvps.org/excel/formula.htm
EDIT: Complementing this nice answer, the worksheet function FormulaText is available for Excel 2013 and later.
This suggestion may be helpful for those who after retrieving a block of formulas and transporting them to a new spreadsheet want to put them to work again. Excels FORMULATEXT function is great for picking up formulas but it leaves them as unusable text strings. If you want to get them back as fully functioning formulas you have to edit each one individually to remove the string character, but here is a shortcut for larger blocks.
Get to the position where you have the required formulas as text (in other words after using FORMULATEXT - you have done a copy and (value only) paste). The next step involves highlighting all the cells you want to convert and then navigating to the [Text-To-Columns] menu option ({Data} bar on Excel 2016). You can select 'Delimited' but on the next screen just make sure you de-select any marks that do appear in your formulas. Then 'Finish'. Excel should automatically analyse the cells as containing formulas and you should now have them working again.
There is a way to do this. In my example I had a table that showed a date. The date comes from Sheet!G91. In my table I also had a column that showed the sheet name. I added two more columns to my table. The first column had column(Sheet!g91), which returns the number 7, because G is the seventh letter in the alphabet. I then converted the number to a letter (G) using another table in my workbook. In the second column that I added, I made a formula row(Sheet!G91), which returns the number 91. Note: Row and Column may appear as volatile formulas, which recalculate with every calculation of the workbook.
I wanted another column to show the formula contents of the date cell mentioned at the beginning of this post. I included the following string function (you can also use CONCATENATE).
"=" & AJ9 & "!" & AM9 & AN9
The items separated by ampersands get strung together (that is, concatenated). AJ9 in my example contains the sheet name, AM9 contains the column letter, and AN9 contains the row number.
I now have a column that dynamically updates its contents to reflect the sheet name and cell reference. The results in my workbook cell are
=Sheet!G91.
You can't. This is most likely a design choice to eliminate an average Excel user from accidentally getting something they did not want.
What you are reading is correct - writing a UDF is the solution you want.