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.
Related
I'm new to StackOverflow and to Excel formulas!
I'm trying to replace the word "GIL64000" with the word "GIB64000", I need to do this across many cells A2: H6; A9: G13, etc.
The cells themselves contain information as follows: "GIL64000_XX_X" with "XX" varying between WH, BL,OR,PU, etc and the"_X" ranging from L, M, S, XL, XXL (shirt sizes).
So I have cells with values like: "GIL64000_OR_S" , "GIL64000_BL_XXL" , "GIL64000_MIN_M" , "GIL64000_MIN_L" etc.
I've tried to get the replace function working by doing this: =REPLACE("GIL64000";3;1; "B")
But it only does this within the cell I have the formula in.
I've tried to add A2: H6 to the formula, but it doesn't accept it and returns with #VALUE! error: =REPLACE(A2:H6;3;1;"B")
I tried some other string like "MID" function, but I can't figure out how to use MID with REPLACE: =REPLACE(MID(A2: H6;3;1; "B"))
I tried to follow some guides and I still can't seem to get it working.
In essence, what I Want is the word "GIL64000" with word "GIB64000" across all my cells and to be able to change the formula as I need it in the future for other values not only "GIL64000"
The REPLACE command only takes in one reference of the cell, and not a range.
Only Change which you need to make is =REPLACE(A2;3;1;"B"), and then just copy the formula (i.e. Ctrl + C, and Ctrl + V on the other cells where you want to change this).
Also, this cannot be applied on the cell itself but would be applied on an adjacent cell.
Let me know if this helps.
There is also the substitute() function which will work, have shown 2 variations - both will drag down, but the second allows customizing the characters to replace. You could put $ on the B3 and C3 for an absolute reference.
See:
Note: I did not just look for "B" although you could - it depends what other data is there...
I know you said you want a formula, but in this case, don't sneeze at the idea of using a CTRL+H. This looks like the perfect scenario for one.
I have a spreadsheet full of references, pretty much every permutation you can imagine.
EX:
='January Scorecard'!F7
='February Scorecard'!F7
='March Scorecard'!H7
='April Scorecard'!H7
I want to be able to change specific things of the formula across an entire row or column. So if I need to change a row where all of the references currently point to 'H7', I want to be able to quickly change all of them to 'F31' or another arbitrary cell value.
What are quick ways to change cells specifically while keeping the reference sheets the same?
You need to use the INDIRECT function. This takes a cell reference which contains text representing a cell address, and converts it into that cell address. So if cell A1 had the text "H7", then your example cells would now have
=INDIRECT("'March Scorecard'!" & A1)
whcih would firstly convert to "'March Scorecard'!H7 " and then the indirect would convert it to ='March Scorecard'!H7
I have a cell formula that's working mixing both text and an If statement, example: ="USER_INPUT" & IF(F2="Asia/Singapore","+08:00","+02:00") output: USER_INPUT+8:00
I'm not the one that will use this formula so I'd like to avoid having the user to search for the "USER_INPUT" in the whole formula in order to prevent mistakes.
Is it possible for the user just to type whatever he want in the cell wihout having the whole formula behind?
example of cell input I want:
="USER_INPUT" & formula
Is there any reason why the cell containing this formula cannot be in another location which the user does not need to edit? So I am suggesting that you have a highlighted cell somewhere for user input (say G2 for the sake of argument), and then in another cell you have the following formula:
=G2 & IF(F2="Asia/Singapore","+08:00","+02:00")
Your display cell can then refer to the cell containing the above formula. You could even take things a step further and lock the cells which contain the actual formulas, to make sure your users don't accidentally change them. Follow the link below for information on how to do that.
https://support.microsoft.com/en-sg/help/214081/xl-how-to-lock-individual-cells-in-a-worksheet
I want to change the formulas in a 200x200 table by using find and replace.
My old formula is ='Sheet1'!A1*IF(B4=C2,1,0) and I want to replace it with =('Sheet1'!A1-'Sheet1'!B1)*IF(B4=C2,1,0)
Since doing it a cell at a time is tedious, I tried to use find and replace, but I could not keep the referenced cells. Is there a way to do it?
This is how the first cells of my data look like
I cannot fill down or right, since if I fill down I want to keep the reference to C2 while changing the reference to B4 (something like B4-$C$2), while if I fill right I want to keep the reference to B4 and change the reference to C2 (something like $B$4-C2)
I think I might have a bit of a workaround, I'd use it for one cell, and then mess about with the IF references depending on your needs for expanding down and right, as without seeing your dataset it's hard to envisage exactly how you want it, I hope this gives you the right idea, but may need a bit of messing about with.
Firstly, you want to get the cell with your original forumula in (let's say it's in A1). In an empty cell (let's say B1), you want to put =FORMULATEXT(A1). Then in another empty cell (let's say C1), you want to put:
="=(" & MID(B1,2,10) & "-Sheet1!B1" & ")" & MID(B1,11,20)
One thing to also maybe note is that my Excel doesn't produce quotes around the Sheet names, so you may need to mess about with the MID numbers (so probably change the 10 in the first mid to a 12, I think?) I've put the final MID number as 20 just to account for longer formulas.
Copy the cell. Now go to a new worksheet and in A1, you want to right click and paste values. Now, this part is important, you want to click into the formula bar and then press enter. This should now give the formula:
=(Sheet1!A1*-Sheet1!B1)*IF(B4=C2,1,0)
Now you can go into the formula bar, copy this and paste it back into your original sheet. Like I said, you should then mess about with the $ for the IF statement depending on your needs for expanding the data. Sorry it's a bit of a long workaround, but it's all I can find to do!
I am horrible with excel. I rarely have to use it but today I do.
I have cells that have images that are comma separated. these cells are in the same column. i need to add a prefix lg_ to each comma separated image in the cell. I have done some reading on concatenate in excel and I am not sure if this is the right method to use. Does anyone have any good tricks/tips to accomplish this?
It currently looks like :
b3f9e6_1008a.jpg,4f57dc_1008d.jpg,9205eb_1008b.jpg,cb1c14_1008.JPG,ad8884_1008c.jpg
the result would look like this:
lg_75c552_599d.jpg,lg_a3a180_599a.jpg,lg_5c2ec4_599e.jpg,lg_dbb052_599b.jpg,lg_419420_599f.jpg,lg_8eb065_599c.jpg
note: images names are different because I just pasted what I already completed manually.
This should be on SuperUser.
What I would do is do Find..Replace on the comma and replace it with ",lg_" (without quotes). Then you need to prepend the strings with "lg_". You can do this by using another column and doing ="lg_"&A1 where you replace A1 with the proper cell reference. Drag this formula down and then copy and paste value that over the initial data.
Edit: Just because you seem new to Excel: To do Find..Replace hit Ctrl + H. The dialog box that will pop up is self explanatory.
This can also be done using the SUBSTITUTE command in a cell formula.
e.g.
Set C30 = "lg_"
Set D30 = "b3f9e6_1008a.jpg,4f57dc_1008d.jpg"
then in E30 type the following: =C30&SUBSTITUTE(D30,",",","&C30)
This does the same as ApplePie's answer, but with the added benefits that you do not need to do a manual replace, and "lg_" is not hard-coded so it can change depending upon the contents of a cell. Therefore you can copy the formula down a column and use different prefixes for each row. e.g.
IF C30="244" and D30="91,99" then E30 = "24491,24499"
IF C31="376" and D31="5,6,7" then E31 = "3765,3766,3767"