Formula on visible cells only - excel-formula

I'm trying to get the below formula to work on visible cells only after I filter out what isn't needed.
=MIN(IF(G7=G6,0,SUMIFS($P$6:$P$760,$A$6:$A$760,A6,$G$6:$G$760,G6)),$B$3)
The formula is checking to see if the line below has the same ID, if it does it places a zero and moves on. If it doesn't match it sums up the value in P that meet the date requirement in A and the ID requirement in G. If the number is less than what's in B3 enter the lesser number. If it's higher than what's in B3 then enter in B3.

Related

Excel formula to Find the last cell with value in a row and add to adjacent cell if there aren't blank

I am trying to find a formula in excel which will find the last cell that has a value and then it to check if the adjacent cells have value and if it has values then it should show the sum until it reaches a blank cell in the reverse direction on cell O1 and also should show the count of the cell in P1.
So, this what I have tried and works, use the below formulas, to accomplish the output you are looking for,
• Formula used in cell O2 --> To get the sum of the values from back until a blank has been found towards left.
=SUM(INDEX(B2:M2,MATCH(2,1/ISBLANK(INDEX(B2:M2,1):
INDEX(B2:M2,MATCH(2,B2:M2,1)))))
:INDEX(B2:M2,MATCH(2,B2:M2,1)))
• Formula used in cell P2 --> To get the counts.
=COUNT(INDEX(B2:M2,MATCH(2,1/ISBLANK(INDEX(B2:M2,1):
INDEX(B2:M2,MATCH(2,B2:M2,1))))):
INDEX(B2:M2,MATCH(2,B2:M2,1)))
Note: Array formulas needs to be committed with CTRL+SHIFT+ENTER and fill down!!!

Excel - Entering Values Automatically into Cells/Columns upon Changing Another Cell Value

Cell B2 has the value for demand, Cell C2 has the value for revenue, Cell D2 has the value for cost, and Cell E2 has the value for profit. In the worksheet, there is a table (or simply put, data) that generates the values for revenue, cost, and profit for any demand between the range 1 to 40. Thus, whenever I update the value in cell B2 to any integer between 1 and 40, the values in cells C2, D2, and E2 change accordingly.
What I want to do is, create a table with columns for demand, revenue, cost and profit. I manually entered the row data for demand, that consists of integers from 1 to 40. Now, I want to have data automatically entered into the rows of other 3 columns for all matching values of demand. For example, row 1 will have demand value 1, and the corresponding values for revenue, cost, and profit (as generated by cells C2, D2, and E2 when cell B2 is 1). Is there a function or VBA I can use to enter corresponding values automatically into all the rows (1-40)? Otherwise, I have to change B2 manually and enter the corresponding values for revenue, cost and profit all manually into the table, one by one. The reason why I need the table is to generate a line chart. Thus, if there is any other idea you've got, also appreciated.
For a simple solution that seems to work for you.
Use the current formulas you are using for the Revenue, Cost, and Profit within the table to calculate them. If you aren't familiar with Excel you can enter the formulas in the first row with respect to the Demand value and drag down from the bottom right hand corner of the cell to automatically copy the formula to the below cells.
Then for your B2, C2, D2, and E2 cells you could use VLookup to choose the correct values from the table based on the entry in cell B2.
If you linked an image of what you are trying to do I could give exact formulas but I believe this would work for your instance.

How to find the maximum value of a given range, dependent on the value in a separate column

Screenshot of the Excel worksheet
I'm working with historic stock prices, and using eight columns I have:
Column A: High
Column B: Low
Column C: Close
Column D: Cx-Cx-4
Column E: Counts the number of consecutive positive numbers in column D
Column F: Counts the number of consecutive negative numbers in column D
Column G: Calculate the difference between the maximum of column A and minimum of column B within a given sequence.
As an example G1 should equal:
=max(A1:A5)-min(B1:B5)
G6 should equal:
=max(A6:A8)-min(B6:B8)
G9 should equal:
=max(A9:A11)-min(B9:B11)
And so on.
I'd like to know if it is possible to automate this calculation, possibly with the use of one or more additional columns.
Welcome to SO!
This may not be the most efficient solution as you need to add two helper columns, but if I understand your requirements correctly, then this idea should work well enough.
First, let's assume that there are 100 rows in your data set. Given that, enter the formula "=A100" in cell G100 and the formula "=B100" in cell H100. This sets up the boundary condition for the formulas in columns G and H. Now, in cell G99, enter this formula:
"=IF(E99="",G100,IF(E100="",A99,MAX(A99,G100)))"
What this formula does is set up a "running maximum" with the following logic:
If the cell in E99 is blank, copy the running maximum from G100, else:
If the cell in E99 is not blank but the cell in E100 is, set up a new running maximum from the cell in A99, else:
Take the maximum of A99 and G100 as the new running maximum.
Similarly, copy the following formula into cell H100:
"=IF(F99="",H100,IF(F100="",B99,MIN(B99,H100)))"
This follows the same logic as the previous formula, but takes the minimum of column B.
Copy or autofill these formulas to the top of the data set. This should now give you running maximum for column A and a running minimum for column B.
The next step is to calculate the difference. I notice from your question, that you only seem to be interested in calculating this difference at the top of each range (G1, G6, G9, etc.), rather than doing it in every row. Given that, we need a slightly more complicated formula.
The boundary condition for this formula is simply "=G1-H1" entered in cell I1. In cell I2, enter this:
"=IF(OR(AND(E2<>"",E1=""),AND(F2<>"",F1="")),G2-H2,"")"
How this works is that it check two conditions that indicate a range boundary:
E1 is blank and E2 is not
or
F1 is blank and F2 is not
If either of these conditions hold, the IF statement is true and "G2-H2" is diplayed, otherwise a blank cell is displayed. Now copy or autofill this formula to the bottom of the data set.
As a final step, you can now hide columns G and H if you don't need them displayed. This should now give you the results I think you're looking for. Please let me know if this doesn't work out for you.

Creating a column formula in excel, changing only one variable

I have a very basic excel file for looking at the cost of shares and calculating a profit/loss %.
I have the initial purchase price in cell E3 and I have the current share price in F3. I have calculated the percentage profit/loss in G3 by the following formula
=(F3/E3)*100 - 100
What I now want is to be able to apply this formula to the whole G column as I enter a new share price into the F column, it will use E3 as a constant in the formula to calculate daily profit/loss. So the new formula I want is effectively;
=(Fi/E3)*100 - 100
Where Fi = F3, F4, F5, F6 and so on...
I have tried dragging the cell down to extend the formula, which works to an extent but it does not keep E3 constant so I get a divide by zero error.
Any suggestions? Thanks
Start with =(F3/E$3)*100 - 100. The $ is an absolute anchor that tells the formula not to change the 3 in E$3 when filled down.
If there is no value in column F, you can have the result returned as a zero-length string (e.g. "") which will make the cell in column G that holds the formula look blank.
=IF(LEN(F3), (F3/E$3)*100 - 100, "")
Use an absolute reference for E3 in the formula:
$e$3
This will lock the reference if you drag the cell down.
The other way around, if you want to lock the character:
=(F3/$E3)*100 - 100

In Excel, what formula can I use to repeat text in one cell, for a specified amount of times in consecutive rows?

In Excel, what formula can I use to repeat text in one cell, for a specified amount of times in consecutive rows?
Example. A2 is the number of times to repeat, B2 is the amount to be repeated and C2, D2, etc is the cells that must receive the repetition?
In C2 .... X2 where X is as far as you may want to go in terms of columns
[updated:I had transposed A&B]
=IF(COLUMN()-2<=$A2,$B2,"")
and copy right
This works by calculating if the current column position -2 exceeds the value in B2
So is column C-2 (3-2 =1) greater than the value in B2
then is column D-2 (4-1 =2) greater than the value in B2 etc
if you question is more complex than this then you will need to provide further detail

Resources