Fetch cell value with increment in row number every day - vba

I have an excel sheet which contain dates in one column (Say column A) and some values corresponding to each date in another column (Say column E). I want to fetch the value from the cell at the intersection of today's date (in column A) and it's corresponding value (in column E).
The value fetched should be assigned to a different cell (say R1). The value should automatically update in R1 since we need to fetch based on today's date.
Please provide me a formula for cell R1.
Example:
-----A----------B---------C--------D--------E
5/8/2015-------------------------------------3
6/8/2015-------------------------------------3
7/8/2015-------------------------------------6
8/8/2015-------------------------------------10
9/8/2015-------------------------------------3
10/8/2015------------------------------------12
11/8/2015------------------------------------3
If today is 10/08/2015, then cell R1 should be filled with the value 12.
Tomorrow R1 should be filled with the value 3 automatically.
Thank you.

You should try this formula in your cell R1:
=VLOOKUP(NOW(), A1:E11, 5, TRUE)
One thing is that if needed, you should modify range A1:E11 as you like.
ADDED
If your R1 cell is in other sheet, use this formula:
=VLOOKUP(NOW(), sheetname!A5:E11, 5, TRUE)
Here, also has one point that you should modify sheetname to your data sheet name.

I'm assuming you want to solve this with a formula, so try this formula in cell R1
=INDEX(D:D;MATCH(TODAY();A:A;0))

Related

Can't figure out what this line does

Can someone please tell me what does this line do:
ActiveSheet.Range("AH1").FormulaArray = "=iferror(MATCH(1,(plan!T3:T20000=AF1)*
(plan!W3:W20000=MONTH(E1)),0),0)+2"
plan is a name of sheet in my Excel file. thanks in advance.
The formula is a doing a multi-criteria CountIF. Without seeing the data, it is doing the following.
Count the data in column T if any of the rows match what is in cell AF1, but only count it if the corresponding month shown in Column W matches the Month shown in cell E1. Then add 2.
this add array formula (usually inserted with Ctrl+Shift+Enter) to the cell AH1. It seems that formula checks if value in column T in plan sheet is equal to this one in AF column and month of date in E column equals to value in plan!W column, plus 2 for some reason.

How do I insert a row in excel and include the inserted row in a formula?

Example:
I have a cell "A1" that sums up some values in a row "IF"-something: =SUM.IF($C$5:$C$10;"Blue";$D$5:$D$10)
meaning: If columns C5 to C10 contains the word "Blue" in any row for example. "C7" and "C9", then the sum of "D7" and "D9" will be shown in "A1".
My problem:
If I insert a new row "5", then I want the formula to contain this row as well:
=SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11)
But what happens is that the formula is now:
=SUM.IF($C$6:$C$11;"Blue";$D$6:$D$11)
So the formula contains only the original 5 rows "5-10" and now named "6-11".
How do I make excel expand the formula to include the new row aswell so it sums up from "5-11" =SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11)?
(I know I can make this work with a table, but this is a thought example and not my real situation. Actually I insert 5 rows at a time, and some cells are merged, so I can't convert the range of data into a table)
Any help is greatly appreciated.
This can't be done. Set the row range reference in the formula to one row above you actual list, then everything should work.
For example, leave row 5 empty. Hide the row if you like. In cell A1, use the formula =SUMIF($C$5:$C$10,"Blue",$D$5:$D$10) (starting at row 5). Start entering values in row 6.
Now you can right-click Row 6 and Insert a new row, and the formula will continue to work as required.

Using CONCATENATE to populate a sum formula in excel vba

I have a spreadsheet that has numbers for a particular year and then subtotals for that year.
The number of instances in a year can vary and there may be a year that doesn't exist i.e., 2018 might be skipped. The title of the totals row is always "FYXX Totals." I have a for loop that goes through the entire column and looks for "FY" Then if it falls within one of three categories (FY1-FY2, FY3-FY7, FY3-FY9; these being variables that represent a year). What I need is for the loop to sum the number in column D, E, F...when "FY" is found. I think using CONCATENATE might be the way to go but I am not sure a) exactly how to do that or b) if that is even the best way to go about it.
Dim rng As Range
Dim SumRow As Integer
Set rng = Range("C4:C" & NextRow)
For Each cell In rng
If Left(cell.Value, 2) = "FY" Then
If 2000 + Int(Mid(cell.Value, 3, 2)) <= FY2 Then 'This is the if statement for the fisrt category
'Here would be the sum function when the if statement is triggered
End If
End If
Next cell
Thanks so much for the help.
SpreadSheet_Picture
The second if loop (right now written for the first category) would need to sum the just the zero that is in column D next to FY17 Total. Keep in mind that sometimes row for FY18 may exist so this macro would have to be able to grab that as well should it exist. But in this case what would have to go into cell "D" & NextRow would be =SUM(D5).
My best attempt at understanding what you're after is that you want to place a formula in each cell of column D where the cell in column C contains FYxx Total, where xx meets certain other criteria. That formula should contain the sum of all the cells in column D for which the cell in the corresponding row of column C contains the same value of FYxx.
The easiest way I can think of to achieve this is to use the SUMIF function:
The formula =SUMIF(B$2:B$999,LEFT(C3,4),D$2:D$999) in cell D3 calculates the sum of all cells in column D where the cell in the corresponding row of column B matches the criterion, i.e. is equal to the first four characters of cell C3.
Unless there are further instances of the same FYxx value elsewhere in column B, the ranges in the first and third arguments of the SUMIF can cover the whole table, which I've assumed here extends to row 999, so you can keep those the same for each cell you place this formula in. You only need to change the row for the cell in column C in the second argument.
In fact if you really want, you can place exactly the same formula in each Total cell in column D:
=SUMIF(B$2:B$999,LEFT(INDEX(C$2:C$999,ROW()-1),4),D$2:D$999)
Here the INDEX function looks up the appropriate cell in column C based on the row of the cell that the function is placed in.

Look for which cell in a row has a numberic value and return that value to another cell

I have a row that only one cell within that row will contain a number value (which could be any number).
On another sheet I need a formula which will find if the number from the row and return me that number value?
Something like that would give you the first number found in column A.
=INDEX(A:A,MATCH(TRUE,INDEX(ISNUMBER(A:A),0),0))
It scans the column until it finds a number and writes it down in the cell.

Excel VBA - selecting the range from first row to the last row

I have a problem with VBA code. I have a sheet with a lot of data around the cells I want. I need to select data in column F, but the position of the first and last cells between the range is to be selected is changing up and down. I created the non empty cells in row X where there is no data do the LastRow function has any refernece but now I dont know how to select the first row
thx for help
If F1 is empty, this selects the first cell with data in the F column
Worksheets("Sheet1").Range("F1").End(xlDown).Select
If F1 may be non-empty you can add a check to see whether it contains text.