Find cells less than todays date VBA - excel

I am trying to create a form which will find any cell with a date value less than todays date within a single column and return the row number. I am trying to use the Match function but only receive errors.
Anybody have any idea where to start with this?
Cheers
James

Ok.
Yes this can be done differently by using VBA, but if you don't know VBA it will be hard. You might be able to use excel formulas like this and this may give you what you need.
If you dates are in column A and start in A1.
Add this formula to B2 and copy it down into the other cells in the column.
=IF(A1<TODAY(),ROW(A1),"After")
This is a starting point.
I don't know what you are using the form for. eg what if many dates are before today, do you just take the first one?
ie
Add this to C1
=IF(B1<>"After",1,0)
Add this to C2 and copy down
=IF(B2<>"After",C1+1,C1)
Add this to D1
=IF(C1<>0,A1,"")
Add this to D2 and copy down
=IF(AND(C2<>0,C1=0),A2,"")
Add this to cell E1
=SUM(D:D)
Chnage column D and E to have date format.
Cell E1 now gives you the first date in the list less than today.
Harvey

Related

Excel Formula required to get the top cell

I am trying to create a bandwidth tracker. I want the date to populate of next available in the Column C.
For example Name E is getting available on 9/18/2021. I want this date to populate in cell C6.
Can any one tell me the formula to be used for this.
Bandwidth Tracker:
Thanks
INDEX/MATCH should work for you. Put below formula C2 cell and drag down till need.
=INDEX($D$1:$I$1,MATCH("Available",D2:I2,0))

Date Manipulation to output the same date

Good day!
Using Excel and would like to multiply a date by a value to create new a row with the same date
Example;
before
Column A
27-OCT-19
execution
Column A Column b
27-OCT-19 X 4
output
Column A
27-OCT-19
27-OCT-19
27-OCT-19
27-OCT-19
I've looked around and it seems that people use Visual Basic - However, I can't use Visual Basic due to permission issues on my network.
If your first date begins in cell A2 then enter this formula in cell B2:
=MID(REPT(TEXT(A2," dd-mmm-yy"),4),2,99)
Now copy the formula downward as far as you need.
Based on your revised question, the following should work.
With your reference date in cell A2 and your multiply value in cell B2 enter this formula in cell A3:
=IF((ROW()-ROW($A$2))<$B$2,$A$2,"")
Now copy the formula downward as far as you need.
If you have Excel O365 with the SEQUENCE function, you can use:
A3: =TRIM(MID(SUBSTITUTE(REPT(TEXT($A$2,"dd-mmm-yy "),B2)," ",REPT(" ",99)),IF(SEQUENCE(B2)=1,1,(SEQUENCE(B2)-1)*99),99))
and the results will SPILL down as far as required.

Referring to a cell in a formula, but wanting to use the cell reference in that cell, not that actual cell itself

I want to make it so I can build a count formula in one sheet that I can just drag down.
the cells being counted are on a different sheet.
Start Ref Date
29-Mar
19-Dec 37
21-Jan 29
28-Feb 14
Essentially what is happening here is that the numbers that are NOT dates are the counted cells between the Ref Date and the Start (what I am tracking doesn't follow a calendar so I can't just subtract the start from the ref date).
I hard coded the count formula to get each of the number of days between ref and start. I'm lazy. I want to make it so the count refers to the referenced value in the start and ref date columns.
current forumla:
=COUNT('SHEET1'!FQ$1:HA$1)
Desired Forumla:
=COUNT($B3:$B$2) where B3 is the referred to start taken from Sheet 1 and B2 is the ref date taken from Sheet 1. That way I only have to change B2 in order to update the count.
How can I refer to a specific value in a cell that is taken from a different sheet???
thanks for the help so far. I'm not sure excel itself can do everything I want it to. I ended up taking an online course in macro's and VBA for Excel.
This solution assumes the dates to count are layed out as below on sheet2:
Lay out your start and reference dates similar to the following:
In cell D3 from the above example, use the following formula:
=COUNTIFS(Sheet2!$C$3:$J$3,">="&Sheet1!B4,Sheet2!$C$3:$J$3,"<="&Sheet1!C4)
That formula can be copied down as required to match your entries for start and reference dates.

Excel: Count every date in a column and give back the sum of dates (preferably in *one* formula)

As you will see in my picture, I do have the following problem: I want to find out whether a value in a cell of column A contains a date or not. In order to do so, I have used the following formula in cells B1:B8:
German Excel formula: =WENN(ISTZAHL(TAG(A1));1;0)
English Excel formula: =IF(ISNUMBER(DAY(A1)),1,0)
As you will quickly notice, it works for B1:B6 but is faulty when it comes to B6:B7, etc.
So: What is wrong with that formula? Column A is formated as TT.MM.JJJJ (or DD.MM.YYYY) as a whole.
If that formula were to work properly, I could easily count the number of dates in column A using column B. But: Is there a way to do this without having to use column B, that is, checking whether a cell in A contains a date and adding it up in one cell with a respective formula?
You need to check if the cell is empty before checking if it's a date:
=IF(A1!='', IF(ISNUMBER(DAY(A1)),1,0), '')
If you want the sum, you can use
=COUNTIF(B16:B23,">32874")
32874 is the decimal representation of 1/1/1900, if you need to parse earlier dates, you can just use 1 too.

Excel Formula Referencing

quick excel question:
If I put values in cell B1 and B2.
Then write the following formula in cell A1:
=$B$1-$B$2
then I highlight cells B1 and B2 and move them to column C. the formula in A1 automatically adjusts for the move ie. formula now becomes:
=$C$1-$C$2
How would I get it to stick to column B and not switch to column C. I tried searching google but did not get right answers (probably am not phrasing question correctly).
The context of my problem is that formulas in one sheet are being calculated based on month end data which is placed in another sheet. Now I need to add April month end data. So I shift the old data to the right and input April's data, but the formulas are automatically adjusting for the shift and still refer to March's month-end data. This despite the formulas using absolute referencing.
Thanks for any help provided
The formula you are looking for is
=INDIRECT("B1")-INDIRECT("B2")
This will always refer to Cells B1 and B2 regardless of what you to do move the cells or add new columns etc.
This will allow you to simply insert a column for the new month.
Not a good spreadsheet design, you should really add new data to a new column.
However, if you are determined to stick to that design, copy and paste the old values to a new column, then delete the originals. Formulas will not be alterd by that.

Resources