find today's date then ...

I need to find the current days date [in Row 3] the I need to insert formulas starting from the cell 2 rows below [so row 5]

My problem is that each day todays date is in a different place i.e. today it's in O3 tomorrow P3 next day Q3 etc.

Originally the date was in J3 so this was easy and I used the below formula. Now I need the same formula to go in the new cells each day so today O5, O7, O0 etc.  

Would appreciate an expert providing the VBA to do this.

Many thanks


    [J5].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-2]C[13]"
    [J7].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-3]C[13]"
    [J9].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-4]C[13]"
    [J11].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-5]C[13]"
    [J13].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-6]C[13]"
    [J15].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-7]C[13]"
    [J17].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-8]C[13]"
    [J18].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-8]C[13]"
    [J20].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-9]C[13]"
    [J22].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-10]C[13]"
    [J24].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-11]C[13]"
    [J25].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-11]C[13]"
    [J27].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-12]C[13]"
    [J28].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-12]C[13]"
    [J30].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-13]C[13]"
    [J32].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-14]C[13]"
    [J33].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-14]C[13]"
    [J35].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-15]C[13]"
    [J36].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-15]C[13]"
    [J38].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-16]C[13]"
    [J43].Select
    ActiveCell.FormulaR1C1 = "=Data!R[-18]C[13]"
JagwarmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamMicrosoft Excel ExpertCommented:
i would not understand the question, can upload a sample data
0
Saqib Husain, SyedEngineerCommented:
Can you upload a sample file?
0
JagwarmanAuthor Commented:
As requested file attached.

I have put in code that would put the formulas in column O in sheet 2 but that is my problem as I said previously.

On Monday the formulas will need to go into P on Tuesday Q etc

So I need to find current date in Row 3 and then insert the formulas in that column.

Thanks and sorry for any confusion.
Find-Today.xlsm
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Glenn RayExcel VBA DeveloperCommented:
Hi,  a couple of questions.

1)  Do you want values ONLY in the column that represents the current date?  By that, I mean do you want all other columns to have no value/result?  
2)  Your example code skipped populating data in rows 40, 41, 45, and 46.  Was that intentional or do you want those values populated also?  I presume rows 40 and 41 would have data from rows 23 and 24 in the Data sheet.
3) Is it necessary to use VBA for this?  One could easily derive a formula to test the date value in row 3 and then produce a result.  For example, this formula could be something like:
J5:  =IF(J$3=TODAY(),DATA!AB3,"")
...which could be copied across all cells on that row.  Variations of that would be inserted for other rows to point to their respective date values.

The advantage of a non-VBA solution would be automatic value recalculation on file open without any macro execution necessary.  But, a solution is possible either way.

Regards,
-Glenn
0
Glenn RayExcel VBA DeveloperCommented:
Just to show a more-concrete example, see the attached workbook.  I've created a single formula that can be copied to all destination cells and set up a look up range on the Data sheet to provide the output.

In cell J5, insert:
=IF(J$3=TODAY(),VLOOKUP(ROW(),Data!$AA$3:$AB$27,2,FALSE),0)
then copy across and throughout all applicable rows.

The Data sheet has a list of destination rows for each value.  Because your conditional formatting rules do not like blank values inserted (produce red results), I have zero be the result for columns NOT matching today's date, then turned off zero values in the sheet options.

-Glenn
EE-Find-Today.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagwarmanAuthor Commented:
Not sure I understand or I did not make clear and maybe I should have said this is a small part of a bigger macro.

each day when the file opens the date [today] will be in a different column, so my macro needs to find the current date then put in the formulas. On Monday the formulas will need to go into P on Tuesday Q etc

Hope this is more clear
0
JagwarmanAuthor Commented:
Glenn Ray

1)  Do you want values ONLY in the column that represents the current date?  By that, I mean do you want all other columns to have no value/result?  ... Yes Correct

 2)  Your example code skipped populating data in rows 40, 41, 45, and 46.  Was that intentional or do you want those values populated also?  I presume rows 40 and 41 would have data from rows 23 and 24 in the Data sheet. .... It was intentional

 3) Is it necessary to use VBA for this?  .... Yes because this is part of a much bigger VBA code.
0
JagwarmanAuthor Commented:
Glenn Ray

Further to my comments above, my problem is, each time the file is opened there are no formulas in the cells at the start of the process which is why I need to find the current days date [in Row 3] then I need to insert formulas starting from the cell 2 rows below [so row 5]

the formulas will always need to go in 5,7,9,11 etc but each day move one column to the right.
0
JagwarmanAuthor Commented:
Glenn Ray

I have found a way to do it using your suggestion so I am all sorted.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.