Excel: Change multiple formulae at once? - excel

I've sorted a chunk of data into sub-totaled fields using the Subtotal tool under the Data tab. However, you are only able to choose one formula to apply.
How can I apply a separate formula to one of the columns based on SUBTOTAL(1,RANGE)? So far I have populated it with Subtotal (9,RANGE), but is there a quicker method to select all of these and change the "9" to a "1"?

Select the column.
Press CTRL+H.
Find What: SUBTOTAL(9
Replace with: SUBTOTAL(1
Click Replace All

Assume your formulae are in the range A1:A5
Open up the VBE by hitting Alt+F11, and enter the following code in a general module of the same workbook
Function GetFormula(Cell As Range) As String
GetFormula = Cell.Formula
End Function
I have got this code from http://dmcritchie.mvps.org/excel/formula.htm
For instructions on how to insert this code in a module, see the 'Where to put the code' section at http://www.cpearson.com/excel/writingfunctionsinvba.aspx
Now, you can extract the formula. Use this formula in a helper column, say column B
=SUBSTITUTE(GetFormula(A1),"(1,","(9,")
Now copy this formula upto where you need, and copy-paste values only back where required.
You can also use this trick to modify any other formulae you need, so I suggest you keep this snippet of code handy :)

Change first or last cell then copy it
select all other cells(you can use Ctrl+Shift+up, down, left or right) then use past special and chose formulas

Related

How to fill the column values in excel?

Its quite basic question, i dont use normally excel and thats why i am struggling. I have labeling data in excel like the picture attached.
Is there any way to fill the vlaues in blank spaces like this:
There are many thousands of rows and i cant fill manually. Any help?
The easiest solution will be to double click on the highlighted.
You can use this way:
Goto special(ctrl+G) -> select blankcell
Use [value code] header column in your image then input the formula as gif
Ctrl + enter -> Copy -> paste as value
If your original data is like first image: just double click on right spot marked
you can use a helper column, and drag the formula to END of data. The formula I've used is =IF(B5<>"";B5;IF(C5<>"";A4;""))
This is what I got after applying formula. Just paste values after that, and delete original column.

How to use VLOOKUP to split multiple-valued cell into separate rows?

As the title says, how do you split this
into
Not sure where the VLOOKUP comes from in your question, but if you have Excel 2010 or later you can do this through PowerQuery
Select your data
Data tab > From Table/Range
You have headers, so choose accordingly
PowerQuery should now start, and within the opened tab:
Start tab > Split column > by delimiter
Obviously choose a comma as delimiter > Choose Advanced and tick by Row instead of Column.
Choose no quotes and confirm.
Right click the data in PQ > Transform > Trim
That's it. You can close PowerQuery now and save your changes
I would post the M code, but my Excel is in Dutch so no use.
If you are not dealing with a massive amount of data, and using Excel 365 or later versions, you can try the following solution.
Suppose your original data is in range A1:A4 including header,
Highlight range B1:B10, go to your formula bar and enter the following formula and confirm it by pressing Ctrl+Shift+Enter on your keyboard:
=FILTERXML("<a><b>"&TEXTJOIN("</b><b>",,SUBSTITUTE(A1:A4,", ","</b><b>"))&"</b></a>","//b")
If you do not want to show the #N/A error, you can use the IFERROR formula in the following way:
=IFERROR(formula,"")
For the logic behind the use of FILTERXML function, you can give a read to this article: Extract word by position using FILTERXML()
The problem with the above solution is that you need to find out what is a reasonable output range for you to enter the array formula so all output can be displayed.
If you have joined the "mysterious" insider program of Excel, you may be able to simply use the UNIQUE function in the following way to get the list (please note the following is only a guess as I am not in the program so cannot test it out).
Highlight cell B1, enter the following formula, hit Enter key as normal.
=UNIQUE(formula)
And the list will be spilled automatically in range B1:B6.
A problem with this formula is that it will only display duplicated values once. Use it with caution.
An alternative is to use SORT function which will also generate a list automatically including duplicated values but they will not be in the same order as the original list if the original list is in random order.

Read value on Sheet1 from Sheet2 using vlookup

I have the following on Sheet1:
Then on Sheet2, I have data. Following is the image.
I want to read the today's and tomorrow's for all the fruits from Sheet2 to Sheet1
I tried vlookup, but it didn't give me a right answer. It was confusing. I also tried to incorporate an if statement with the vlookup, but that made it more confusing.
If you data is consistent, you can use this formula =IF(C$2="Today",INDEX(Sheet2!$D$3:$D$800,MATCH($B3,Sheet2!$B$3:$B$800,0)),INDEX(Sheet2!$D$3:$D$800,MATCH($B3,Sheet2!$B$3:$B$800,0)+1)) in cell C3. drag formula below whole table...
Maybe there is way to match with blank cells in between, but the best practice is to fill out those blanks to save your time and make the formula clean, moreover, it is very easy with this trick:
First, highlight the column (ie. B1 to B6), and then go Home > Editing > Find & Select > Go To Special > Blanks > OK, =, upper arrow key, Ctrl + Enter. This way it will fill out all the blanks with the most available text in it.
Then you can perform this easy formula to do the subtotal task:
=SUMIFS($I$3:$I$13,$G$3:$G$13,$B3,$H$3:$H$13,C$2)
Please note that I put everything in the same tab to show you how this is being done. You should change those ranges accordingly based on your data setup. This way, you can have more data and different criteria be added on and still get the correct answer as I have shown you in the above screenshot.

Excel conditional that is in the same cell as an input

I am trying to work an excel spread sheet at the moment. Everything is going fine bar for this issue.
I am building a conditional statement and If I create an extra row and place this formula into it works perfectly.
=IF(G2="M","M",IF(G2="m", "M", IF(G2="d", "D", IF(G2="D","D", IF(G2="n", "N", IF(G2="N","N", "O"))))) )
What I would like to do is have the input cell and the result's output in the same cell.
Could anyone give me a quick steer in how to resolve the problem?
You can't do that as your input would overwrite the formula.
VBA is the way to to go if that's what you need.
Hide the column having the formula, and put the value of formula on next column. For example if your complex formula is on K column (let's say K2), you just need to hide K, and put following on L2:
=K2
Or, you may protect the sheet/workbook after protecting the formulas, since your idea is to hide the formulas! Just the "Format Cells" dialog, and see Protection tab. Now, you need to search on how to use it.
Use Data Validation with a DropDown and allow D,M,N,O

Copying cells from one worksheet to another if a column matches a value

I'm trying to use formula to copy data from one worksheet to another where a column matches a certain value.
To be more specific, I want Working!A2:E100 to contain Data!A2:E100 but only for those rows where Data!C2:100 contains the value "Fixed".
Doing this with leaving blank rows is simple, I just create the formula:
=IF(Data!$C2="Fixed", Data!A2, "")
And copy that formula across all the cells.
But then I thought I'd get clever and have it not copy across blank lines, and entered a maze of unclear excel tutorials and vague error messages.
I've created this formula:
=INDEX(Data!A2:Data!A200, MATCH("Fixed", Data!$C$1:Data!$C$200, 0))
And entered it as an array formula using ctrl shift enter.
However all I get is the contents of Data!A2 repeated over and over in every cell of my spreadsheet.
Does anyone need to know what I need to do to make this work?
This is my attempt at a local prototype following the example in BruceWayne's answer, the results are visible:
As you can see "Row 2" just appears repeatedly in the result column. Excel doesn't seem to have an easy way to see what version it is any more but this seems to be a pretty recent one, it's got the ribbon with the file menu and all menu headings are capitalized.
Here's a formula you can use (note: enter this as an array):
=IFERROR(INDEX(A$1:A$200,SMALL(IF(C$1:C$200="Fixed",ROW(A$1:A$200)-ROW(A$1)+1),ROWS(A$1:A1))),"")
You may need to tweak the ranges, I think I got them to match yours, but again, probably need to tweak. You can then drag this down, and it'll fill in with the values from column A, skipping any blanks.
Edit: Here's a screenshot to (hopefully) help show what I did:
You can edit the ranges, naturally, to be over two sheets.
To clarify, A$1:A$200 is the range of what you want to return (the index). C$1:C$200 is the range that holds "Fixed".

Resources