How do I stop a formula if the cell is blank? - excel-formula

How do I stop a formula from running if there is no data in the cell to the left?
I'm trying to work out how to display elapsed time using a fixed time and a dynamic clock.
My fixed time is in Cell D5 and my dynamic clock in Cell J4 (picture attached). To work out 'elapsed time' my forumla is as follows; =J4-D5, which works fine. However, when I copy the forumla down if there is no data in cells D6,D8,D9 etc, then it will just display the current time.
Is there some error checking that I can do that will only run the forumla if there is data present in Column D?
I am very new to excel, so apologies for the noob question.
Many thanks

If(D5 = "","",J4-D5)
Explanation:
IF D5 = "empty String" THEN "empty string". Else J4-D5.

Related

How do I get around circular reference

I need help to go around circular refence on my code.
What the code does is copy a value from cell A2 unto a cell in the same row using the date in Row1 as reference. =IF(C1=$A$1, IF(ISBLANK($A2), ,$A2), ) .
This code does the job but the problem is when I change the date on Cell A1 to say like September 2, the value on Cell C2 returns to 0, I want it to maintain it's value after changing the date at cell A1.
This last image would be the ideal output but the code has circular reference which is not ideal as the whole sheet has 365days each row January1 to December31 and has 200rows.
The code =IF(C1=$A$1, IF(ISBLANK($A2), ,$A2), C2 )
What you are trying to ask it to do is:
IF my date header matches my date input header, then give me the cell details.
The problem is that when you change the date header it's no longer going to match for different dates and is going to re-evaluate with a 0. That's why this doesn't work.
Anytime you adjust that formula again, it's going to re-evaluate and you're going to be back to square 1.
That's why I can't give you a formula based answer BUT:
When the cell has taken it's reference for that date highlight it (eg. C2), press F2, and then press F9. It'll remove the formula and just leave the value behind. You have to do this before changing the header for A1 again.
If you're savvy, you can turn this into a macro. :)

How do i make a cell in excel stop calculating?

I'm using wps spreadsheet which is similar to excel.
I'm trying to make a cell stop calculating at the end of the month, and keep the number of last day existing.
the existing code in k2 is:
=SUM(E2-I2)
For example: if on 01/31/2022 cell K2 says $2,000, then on 02/01/2022 it still says $2,000 but no longer grabs input from E2 and I2?
Thank you!
Let's say that the date the CELL K2 is updated is in Cell "MyDate", use this formula in K2. When the month doesn't match it stop.
=IF(MONTH(MyDate)=MONTH(NOW()),SUM(E2-I2),K2)
If needed you can also add the YEAR.

How to check if a cell is the 17th of any month

I have a column of dates (daily) and I want an IF statement that will check if the corresponding cell is the 17th of any month.
I'm happy with the syntax of if statements but am unsure how I should be using wildcards here. 'x'below can be any numerical value.
The cell in question looks like - 17/07/2019.
= IF( cell = 17/**/****,x,0)
Excel gets confused and tries to show me how to do maths without a formula.
If you already know that the date is not a text value you can use a simple formula like:
=IF(DAY(A1)=17,”x”,0)
The only issue is that your dates may be genuine Excel dates or text values. With data in A1, in another cell enter:
=IF(ISNUMBER(A1),IF(DAY(A1)=17,"X",0),IF(LEFT(A1,2)="17","X",0))

Distribute the value of a cell over multiple cells untill the remaining value is 0

I'm looking for a solution to automatically distribute the value of a cell (C3 till C10) based on the number of months (B7 till B10).
Anyone who can help me out with this formula?
First, you can make a helper row as showed in image attached starting with number 1.
Then apply below formula to cell(E5) and drag across the range.
Formula: "=IF($B5>=E$3,$C5/$B5,0)"
Related Image
Thanks
Abhinav
Type the following formula into cell E7:
= IF(COLUMN()-COLUMN($E7)+1<=$B7,$C7/$B7,0)
Then drag this cell over and then down as far as you need it.
For second part, to calculate amount of months you can add formula in cell("C4") as:
=MONTH(DATEVALUE(C3&"1"))-MONTH(C2)+1

VBA to shift formula reference down one row

I'm currently working on a massive file, that compares year/year data.
Every week I need to update a formula in the file to move down a row. I want to make a command button to update these formulas.
Here is a simple example
cell c800 contains: =((C235-C229)/C229)*100
I would like to click the button to make the cell update to
=((C236-C330)/C330)*100
Can anyone help me out here? is this possible? I've been looking all over for this and can't find anything.
thanks
Enter this formula in C800 and it will always capture any newly added lines of data.
=(INDEX(C5:C799,MATCH(1E+99,C5:C779,1))-INDEX(C5:C799,MATCH(1E+99,C5:C779,1)-6))/INDEX(C5:C799,MATCH(1E+99,C5:C779,1)-6)*100
assumes first data point is in C5. Change as needed
This works because MATCH(1E+99,C5:C799,-1) finds the last numerical value in the column.
there is a function to do that, as if the cell containing the formula was copied somewhere else and the cell references in the formula were shifted/moved:
strFormulaMoved$ = Application.ConvertFormula(Application.ConvertFormula(Selection.Formula, XlReferenceStyle.xlA1, XlReferenceStyle.xlR1C1, , Range("C800")), XlReferenceStyle.xlR1C1, XlReferenceStyle.xlA1, , Range("C800").Offset(1, 0))

Resources